/* Lemon HR — bảng màu trung tính (xám than / giấy) + MỘT điểm nhấn vàng chanh dùng tiết kiệm (vạch trên thanh đầu trang, vạch mục menu đang
   mở, viền thẻ đăng nhập, biểu tượng). Chữ trên nền vàng LUÔN tối (--lemon-ink) — chữ trắng trên vàng không đủ tương phản. Nút chính =
   xám than chữ trắng. Phẳng, không gradient / kính mờ / glow. Mặc định sáng; <html data-theme="dark|light">.
   Mọi màn hình dùng các biến này; không tự đặt màu cứng ngoài khối biến. */
:root {
  --lemon: #F2CE16;
  --lemon-ink: #2A2604;
  --charcoal: #26292E;
  --brand: var(--charcoal);
  --brand-dark: #121417;
  --brand-soft: #ECEDEF;
  --accent: var(--lemon);
  --accent-dark: #C9A800;
  --accent-text: #5E4F00;
  --accent-soft: #FFF7CF;
  --ink: #23262B;
  --muted: #676B72;
  --line: #E3E4E7;
  --bg: #F5F5F3;
  --surface: #FFFFFF;
  --surface-2: #F0F0EE;
  --hover: #F7F7F5;
  --ok: #1E8E4E;
  --ok-soft: #E5F3EA;
  --ok-text: #17703D;
  --warn: #8F5B06;
  --warn-soft: #FDF3E1;
  --err: #C4361C;
  --err-soft: #FBE9E5;
  --btn-border: #D3D5D9;
  --soon: #A3A6AC;
  --shadow: 0 1px 2px rgb(35 38 43 / .05);
  --overlay: rgb(20 22 25 / .45);
  --radius: 8px;
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --brand: #E6E4DF;
  --brand-dark: #F4F2EE;
  --brand-soft: rgb(255 255 255 / .08);
  --accent: #F5D53A;
  --accent-dark: #F5D53A;
  --accent-text: #F5D53A;
  --accent-soft: rgb(245 213 58 / .13);
  --ink: #ECEBE8;
  --muted: #A3A5AA;
  --line: rgb(255 255 255 / .09);
  --bg: #17181A;
  --surface: #202124;
  --surface-2: #28292C;
  --hover: #2D2E31;
  --ok: #5CCB8A;
  --ok-soft: rgb(92 203 138 / .14);
  --ok-text: #7FDBA4;
  --warn: #F0BE5A;
  --warn-soft: rgb(240 190 90 / .13);
  --err: #FF8A78;
  --err-soft: rgb(255 138 120 / .13);
  --btn-border: rgb(255 255 255 / .16);
  --soon: #66696E;
  --shadow: 0 1px 2px rgb(0 0 0 / .3);
  --overlay: rgb(0 0 0 / .6);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); min-height: 100vh; -webkit-font-smoothing: antialiased; }
a { color: var(--brand-dark); }
button, input, select, textarea { font: inherit; color: inherit; }
:root[data-theme="dark"] a { color: var(--brand-dark); }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.main > * { animation: fadein .22s ease both; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---- Đăng nhập ---- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); background: var(--bg); }
.login-side { background: var(--charcoal); color: #fff; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-side h2 { font-size: 30px; line-height: 1.25; margin: 0 0 12px; font-weight: 700; max-width: 420px; }
.login-side p { margin: 0; opacity: .85; max-width: 420px; }
.login-side .bar { width: 48px; height: 4px; background: var(--lemon); margin-bottom: 20px; }
.login-side small { opacity: .7; font-size: 12px; }
.login-side .side-logo { display: flex; align-items: center; gap: 14px; }
.login-side .side-logo .lemon-mark { height: 56px; width: auto; }
.login-side .side-logo .wm { height: 44px; width: auto; }
.login-main { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--lemon); border-radius: var(--radius); padding: 32px; width: 100%; max-width: 400px; }
.login-card .logo .lemon-mark { height: 40px; }
.login-card .logo .brand-word .wm { height: 30px; }
.login-card h1.login-title { font-size: 20px; margin: 22px 0 4px; font-weight: 700; }
.login-card .btn.primary { height: 42px; }
/* HQ-68: nút Đăng nhập bằng Lark (nổi bật) + link mở ô mật khẩu */
.login-card .lark-btn { display: flex; align-items: center; justify-content: center; width: 100%; text-decoration: none; font-weight: 600; }
.login-card .lark-hint { font-size: 12px; margin: 8px 0 14px; }
.login-card .lark-toggle { background: none; border: 0; padding: 0; color: var(--brand-dark); cursor: pointer; font: inherit; text-decoration: underline; margin-bottom: 12px; }
.login-card #loginForm[hidden], .login-card .lark-box[hidden] { display: none; }
/* Passkey (port ZAO-1) — nút phụ dưới form; bước 2 "Dùng passkey thay mã"; lời mời tạo passkey (nút chữ "Không hỏi lại") */
.login-card .passkey-box { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.login-card .passkey-box[hidden], .login-card .mfa-passkey[hidden], .login-card #loginSubmit[hidden] { display: none; }
.login-card .passkey-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 40px; font-weight: 600; }
.login-card .passkey-btn svg { flex: none; }
.login-card .passkey-hint { font-size: 12px; margin: 8px 0 0; }
.login-card .mfa-passkey { margin: 0 0 12px; }
.passkey-list .muted { font-size: 12px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand-dark); cursor: pointer; font: inherit; font-size: 13px; text-decoration: underline; }
@media (max-width: 860px) { .login-wrap { grid-template-columns: minmax(0, 1fr); } .login-side { display: none; } }

/* Logo Lemon Digital: biểu tượng (PNG) + chữ LEMON DIGITAL (ảnh: bản chữ tối / chữ trắng theo theme) + nhãn HR */
.logo { display: inline-flex; align-items: center; gap: 9px; margin: 0; font-weight: 700; text-decoration: none; color: var(--charcoal); }
.logo .lemon-mark { height: 30px; width: auto; display: block; flex: none; }
.logo .brand-word { display: inline-flex; align-items: center; }
.logo .brand-word .wm { height: 22px; width: auto; display: block; }
.logo .brand-word .wm-dark, :root[data-theme="dark"] .logo .brand-word .wm-light { display: none; }
:root[data-theme="dark"] .logo .brand-word .wm-dark { display: block; }
.logo .brand-tag { font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--brand-dark); border: 1px solid currentColor; border-radius: 4px; padding: 1px 6px; }
:root[data-theme="dark"] .logo, :root[data-theme="dark"] .logo .brand-word { color: var(--ink); }
:root[data-theme="dark"] .avatar { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }

/* ---- Khung ứng dụng ---- */
.topbar { height: 56px; display: flex; align-items: center; gap: 14px; padding: 0 18px; background: var(--surface); border-top: 3px solid var(--lemon); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: 13px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: #fff; background: var(--charcoal); flex: none; border: 0; cursor: pointer; }
.layout { display: flex; min-height: calc(100vh - 56px); }
.sidenav { width: 220px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--line); padding: 10px; transition: width .15s; }
.sidenav .group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 16px 10px 6px; font-weight: 600; }
.sidenav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; position: relative; transition: background .12s; }
.sidenav a svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }
.sidenav a:hover { background: var(--hover); }
.sidenav a.active { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.sidenav a.active svg { opacity: 1; }
.sidenav a.active::before { content: ""; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 3px; background: var(--lemon); }
.sidenav a.soon { color: var(--soon); pointer-events: none; }
.navtoggle { width: 100%; justify-content: flex-start; margin-bottom: 4px; color: var(--muted) !important; }
body.nav-collapsed .sidenav { width: 64px; }
body.nav-collapsed .sidenav .group { visibility: hidden; height: 6px; margin: 8px 0; }
body.nav-collapsed .sidenav a span, body.nav-collapsed .navtoggle span { display: none; }
body.nav-collapsed .sidenav a { justify-content: center; }
.main { flex: 1; padding: 24px 28px; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; flex: 1; font-weight: 700; }

/* ---- Thành phần ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.btn { border: 1px solid var(--btn-border); background: var(--surface); padding: 7px 14px; min-height: 36px; border-radius: 6px; cursor: pointer; transition: border-color .12s, background .12s, transform .12s, box-shadow .12s; }
.btn:hover { border-color: var(--brand); background: var(--hover); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
:root[data-theme="dark"] .btn.primary, :root[data-theme="dark"] a.btn.primary { color: #16181B; }
.btn.mint { background: var(--accent); border-color: var(--accent); color: var(--lemon-ink); font-weight: 600; }
.btn.small { padding: 3px 10px; font-size: 13px; min-height: 28px; }
.btn.icon { padding: 4px 9px; min-height: 32px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea {
  border: 1px solid var(--btn-border); border-radius: 6px; padding: 7px 11px; min-height: 36px; background: var(--surface); min-width: 0; transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--muted); }
.field-label { font-size: 13px; color: var(--muted); }
.field .req { color: var(--err); }
.check-list { display: grid; gap: 7px; max-height: 190px; overflow-y: auto; padding: 9px 11px; border: 1px solid var(--btn-border); border-radius: 10px; background: var(--surface-2); }
.check-list label { display: flex; align-items: flex-start; gap: 7px; color: var(--ink); cursor: pointer; }
.check-list input { margin-top: 4px; }
.catalog-required::after { content: " *"; color: var(--err); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }   /* minmax(0): ô chọn có lựa chọn dài không đẩy cột tràn khỏi hộp thoại */

table.data { width: 100%; border-collapse: collapse; background: var(--surface); }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { font-size: 12px; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; z-index: 1; font-weight: 600; }
table.data tbody tr { transition: background .1s; }
table.data tbody tr:hover td { background: var(--hover); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 10px; color: var(--muted); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.badge[hidden] { display: none; }   /* HQ-47: display của .badge thắng thuộc tính hidden ⇒ chấm xám rỗng (VD thẻ Order Legal chưa có order) */
.badge.ok { background: var(--ok-soft); color: var(--ok-text); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }

.msg { padding: 9px 13px; border-radius: 6px; margin-bottom: 12px; }
.msg.err { background: var(--err-soft); color: var(--err); }
.msg.ok { background: var(--ok-soft); color: var(--ok-text); }
.msg.info { background: var(--brand-soft); color: var(--brand-dark); }
.msg.warn { background: var(--warn-soft); color: var(--ink); border-left: 3px solid var(--warn); }   /* HQ-59: hộp hậu quả / cảnh báo không chặn */
.msg ul { margin: 6px 0 0; padding-left: 18px; }
.msg li + li { margin-top: 3px; }

.modal-bg { position: fixed; inset: 0; background: var(--overlay); display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; width: 100%; max-width: 560px; box-shadow: 0 12px 40px rgb(0 0 0 / .18); animation: fadein .18s ease both; }
.modal header { padding: 15px 20px; border-bottom: 1px solid var(--line); font-weight: 700; display: flex; }
.modal header .x { margin-left: auto; cursor: pointer; border: 0; background: none; font-size: 18px; color: var(--muted); }
.modal .body { padding: 18px 20px; }
.modal footer { padding: 13px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; z-index: 60; max-width: calc(100vw - 32px); }
.toast { padding: 10px 15px; border-radius: 6px; color: #fff; background: var(--charcoal); border: 1px solid rgb(255 255 255 / .12); z-index: 60; box-shadow: 0 10px 28px rgb(0 0 0 / .35); animation: fadein .18s ease both; }
.toast.err { background: #B5321A; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: thin; }   /* HQ-26: nhiều tab ⇒ cuộn ngang trong thanh tab, không tràn trang */
.tabs a { padding: 9px 15px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; flex: 0 0 auto; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--brand-dark); border-bottom-color: var(--brand); font-weight: 600; }
.catalog-tabs { overflow-x: auto; }
.catalog-tabs a { white-space: nowrap; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.muted { color: var(--muted); }

/* Tổng quan (dùng cho chi tiết cửa hàng trong hệ thống) */
.filters { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: flex-end; margin-bottom: 16px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.filters input, .filters select { min-width: 150px; }
.kpi-wrap { display: grid; gap: 14px; margin-bottom: 18px; }
.kpi-group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; border-top: 3px solid var(--line); box-shadow: var(--shadow); transition: transform .15s; }
.kpi-group.total { border-top-color: var(--lemon); }
.kpi-group h3 { margin: 0 0 10px; font-size: 15px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 2px 0; overflow-wrap: anywhere; letter-spacing: -.01em; }
.kpi-sub { font-size: 12px; }
.delta { font-weight: 600; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--err); }
.delta.up::before { content: "▲ "; font-size: .8em; }
.delta.down::before { content: "▼ "; font-size: .8em; }
.note { font-size: 12px; margin: 10px 0 0; }
.seg { display: flex; gap: 6px; margin-bottom: 10px; }
.chart { margin-bottom: 12px; }
.chart svg { width: 100%; height: 180px; display: block; background: var(--surface-2); border-radius: 10px; }
.chart-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 4px; }

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidenav, body.nav-collapsed .sidenav { width: auto; border-right: 0; border-bottom: 1px solid var(--line); display: flex; overflow-x: auto; gap: 4px; padding: 8px; }
  .sidenav .group, .sidenav .navtoggle { display: none; }
  .sidenav a, body.nav-collapsed .sidenav a { white-space: nowrap; justify-content: flex-start; }
  body.nav-collapsed .sidenav a span { display: inline; }
  .sidenav a.active::before { display: none; }
  .main { padding: 16px; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .tabs { overflow-x: auto; }   /* nhiều tab (dự án 7 tab) không đẩy trang tràn ngang ở 390 px */
  .tabs a { white-space: nowrap; flex: none; }
  .filters input, .filters select { min-width: 0; width: 100%; }
  .filters label { flex: 1 1 140px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 19px; }
  .chat-bubble { max-width: 100%; }
  .topbar .who { display: none; }
  .topbar .brand-word { display: none; }   /* 390 px: chỉ giữ biểu tượng + nhãn HR */
  table.data td, table.data th { white-space: nowrap; }
}

/* ---- Khung cố định: header + menu đứng yên, chỉ vùng dữ liệu cuộn (desktop) ---- */
@media (min-width: 761px) {
  html, body { height: 100%; }
  body { overflow: hidden; }
  #app { height: 100%; display: flex; flex-direction: column; }
  .layout { flex: 1; min-height: 0; }
  .sidenav { overflow-y: auto; }
  .main { overflow-y: auto; }
  .table-wrap.fit { overflow: auto; }
  .table-wrap.fit table.data th { box-shadow: 0 1px 0 var(--line); }
}

/* Bảo mật tài khoản */
.security-grid { display: grid; gap: 18px; }
.security-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.security-card-head h2 { font-size: 17px; margin: 0 0 4px; }
.security-card-head p { margin: 0; }
.security-sessions { min-width: 0; }
/* HQ-53a thẻ "Email hệ thống" (Admin, views/mail_admin.js) */
.mail-admin { min-width: 0; }
.mail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.mail-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0 0 14px; font-size: 14px; }
.mail-facts dt { color: var(--muted); }
.mail-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.mail-hint { background: var(--warn-soft); color: var(--ink); border-radius: var(--radius); padding: 10px 12px; margin: 0 0 14px; font-size: 14px; }
.mail-err { font-size: 13px; margin-top: 4px; color: var(--err); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mail-list { border: 1px solid var(--line); border-radius: var(--radius); }
.mail-row { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; padding: 10px 12px; border-top: 1px solid var(--line); }
.mail-row:first-child { border-top: 0; }
.mail-main { min-width: 0; flex: 1; }
.mail-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mail-line .badge { white-space: nowrap; }
.mail-subject { font-weight: 600; margin-top: 4px; overflow-wrap: anywhere; }
.mail-token { font-weight: 400; font-size: 12px; }
.mail-addr { font-size: 13px; overflow-wrap: anywhere; }
.mail-text { white-space: pre-line; margin-top: 4px; font-size: 14px; overflow-wrap: anywhere; }
.mail-btns { display: flex; gap: 6px; flex-shrink: 0; }
.mail-btns .btn { white-space: nowrap; }
@media (max-width: 760px) { .mail-facts { grid-template-columns: 1fr; } .mail-facts dd { margin-bottom: 6px; } .mail-row { flex-direction: column; gap: 6px; } .mail-btns [data-eml] { display: none; } }   /* điện thoại: ẩn "Tải .eml" cho hàng gọn */
.mfa-qr { display: flex; justify-content: center; margin: 4px 0 18px; }
.mfa-qr img { display: block; width: 220px; height: 220px; max-width: 100%; border-radius: 10px; background: #fff; padding: 8px; }
.mfa-secret { display: block; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }

/* ---- Sales: Lead / Account / Client / Cơ hội / Hợp đồng ---- */
input[type=datetime-local] { border: 1px solid var(--btn-border); border-radius: 6px; padding: 7px 11px; min-height: 36px; background: var(--surface); min-width: 0; }
.check-inline { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; color: var(--muted); cursor: pointer; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 6px 0 10px; }
.section-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 12px; }
.seg .btn.primary { pointer-events: none; }

/* Timeline hoạt động / lịch sử trạng thái */
.timeline { display: grid; gap: 0; border-left: 2px solid var(--line); margin-left: 8px; }
.timeline-item { position: relative; padding: 4px 0 14px 18px; }
.timeline-item::before { content: ""; position: absolute; left: -7px; top: 10px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--brand); }
.timeline-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.timeline-head .muted { font-size: 12px; }
.timeline-note { margin-top: 4px; white-space: pre-wrap; }

/* Kanban cơ hội */
.kanban { display: grid; grid-template-columns: repeat(3, minmax(240px, 1fr)); gap: 14px; align-items: start; }
.kanban-col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 240px; transition: border-color .12s, background .12s; }
.kanban-col.over { border-color: var(--accent); background: var(--accent-soft); }
.kanban-col h3 { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 2px 4px 10px; }
.kanban-col h3 .kanban-sum { margin-left: auto; font-size: 12px; font-weight: 500; }
.kanban-cards { display: grid; gap: 8px; }
.kanban-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow); cursor: grab; display: grid; gap: 4px; }
.kanban-card[draggable="true"]:active { cursor: grabbing; }
.kanban-card.dragging { opacity: .5; }
.kanban-card .kanban-title { font-weight: 600; }
.kanban-card .kanban-title a { text-decoration: none; }
.kanban-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.kanban-meta strong { color: var(--ink); }
.kanban-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 2px; }
.kanban.six { grid-template-columns: repeat(6, minmax(200px, 1fr)); overflow-x: auto; }  /* Plan: 6 cột theo stage */
.kanban-card .kanban-days { font-size: 12px; color: var(--muted); }
@media (max-width: 900px) { .kanban { grid-template-columns: 1fr; } }

/* Tổng quan Sales (#/overview): bộ lọc, ô số liệu, thanh ngang (phễu / theo stage), lưới thẻ */
.ov-toolbar { align-items: flex-end; }
.ov-filter { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.ov-period { margin: -8px 0 14px; font-size: 13px; }
.ov-tiles { margin-bottom: 18px; }
.ov-tiles .kpi-value { font-variant-numeric: normal; }
.ov-tone-ok { color: var(--ok-text); }
.ov-tone-warn { color: var(--warn); }
.ov-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; margin-bottom: 18px; }
.ov-card { min-width: 0; }
.ov-card .table-wrap { box-shadow: none; }
.ov-title { font-size: 15px; margin: 0 0 12px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.ov-note { font-size: 12px; font-weight: 400; }
.ov-bars { display: grid; gap: 10px; }
.ov-row { display: grid; grid-template-columns: minmax(96px, 150px) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.ov-label { color: var(--muted); overflow-wrap: anywhere; }
.ov-track { display: block; height: 18px; border-radius: 0 4px 4px 0; background: var(--surface-2); overflow: hidden; }
.ov-fill { display: block; height: 100%; background: var(--brand); border-radius: 0 4px 4px 0; }
.ov-fill.ok { background: var(--ok); }
.ov-fill.err { background: var(--err); }
.ov-num { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.ov-num small { color: var(--muted); font-size: 12px; }
@media (max-width: 760px) {
  .ov-filter { flex: 1 1 140px; }
  .ov-filter input, .ov-filter select { width: 100%; }
  .ov-grid { grid-template-columns: 1fr; }
  .ov-row { grid-template-columns: minmax(80px, 110px) 1fr auto; }
  .ov-num { white-space: normal; }
}

/* ---- Trang bản ghi kiểu Salesforce / Odoo (đợt UX 1) ---- */
.crumb { font-size: 13px; color: var(--muted); margin: -4px 0 6px; display: flex; gap: 6px; align-items: center; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--brand-dark); text-decoration: underline; }
.path { display: flex; gap: 4px; margin: 4px 0 8px; flex-wrap: wrap; }
.path-step { flex: 1 1 0; min-width: 110px; text-align: center; padding: 9px 14px; font-size: 13px; font-weight: 600; color: var(--muted);
  background: var(--surface-2); border: 0; clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%, 12px 50%); font-family: inherit; }
.path-step:first-child { clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%); border-radius: 8px 0 0 8px; }
.path-step:last-child { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 12px 50%); border-radius: 0 8px 8px 0; }
.path-step.done { background: var(--brand-soft); color: var(--brand-dark); }
.path-step.current { background: var(--brand); color: var(--surface); }   /* tối: nền sáng ⇒ chữ tối (chữ trắng chỉ 1,3:1) */
.path-step.current.bad, .path-step.bad { background: var(--err); color: #fff; }
.path-step.can { cursor: pointer; }
.path-step.can:hover { background: var(--brand-soft); color: var(--brand-dark); }
.path-step.blocked { cursor: not-allowed; opacity: .55; text-decoration: line-through dotted; }   /* HQ-55: còn thiếu điều kiện (title = lý do) */
.path-guide { font-size: 13px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; }
.highlights { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 18px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 16px; margin: 0 0 12px; box-shadow: var(--shadow); }
.hl-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.hl-value { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; margin-top: 2px; }
.tab-count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 6px; border-radius: 10px; font-size: 11px; line-height: 18px; text-align: center;
  background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; }
.tab-count.zero { background: var(--surface-2); color: var(--muted); }
@media (max-width: 720px) { .path-step { min-width: 0; padding: 8px 10px; font-size: 12px; } }

/* ---- HQ-17: Việc của tôi, chip lọc nhanh (Odoo favorites), ô chọn khách, thẻ dự án (Khách hàng 360) ---- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 10px; }
.chip { border: 1px solid var(--btn-border); background: var(--surface); color: var(--muted); padding: 4px 12px; min-height: 30px; border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .12s, color .12s, border-color .12s; }
.chip:hover { border-color: var(--accent-dark); color: var(--ink); }
.chip.on { background: var(--brand-soft); color: var(--brand-dark); border-color: var(--brand); }
.chip.on::before { content: "✓ "; }
/* HQ-23: nút "Bộ lọc" (bộ lọc lưu sẵn) cuối hàng chip + bảng nhóm theo */
.chips { position: relative; z-index: 3; }   /* .main > * có animation fill both ⇒ mỗi khối là một stacking context: hàng chip phải nổi trên bảng để menu "Bộ lọc" không bị bảng che */
.chips .fmenu { position: relative; margin-left: auto; }
.fmenu-btn.on { background: var(--brand-soft); color: var(--brand-dark); border-color: var(--brand); font-weight: 600; }
.fmenu-pop { right: 0; left: auto; min-width: 280px; max-width: min(380px, calc(100vw - 32px)); max-height: min(70vh, 520px); overflow-y: auto; }
.fmenu-head { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 10px 4px; }
.fmenu-row { display: flex; align-items: center; gap: 2px; }
.fmenu-pop .fmenu-row button { width: auto; }
.fmenu-pop .fmenu-row .fmenu-apply { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.fmenu-row.on .fmenu-apply { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.fmenu-pop .fmenu-row .fmenu-more { flex: none; width: 34px; text-align: center; color: var(--muted); font-weight: 700; }
.fmenu-star { color: var(--warn); }
.fmenu-sub { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.fmenu-empty { padding: 4px 10px 10px; font-size: 12px; }
.fmenu-sep { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
table.data tr.grp td { background: var(--surface-2); padding: 6px 10px; border-top: 1px solid var(--line); }
.grp-toggle { border: 0; background: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; font: inherit; color: var(--ink); padding: 2px 0; }
.grp-toggle .grp-caret { display: inline-block; color: var(--muted); transition: transform .12s; }
.grp-toggle[aria-expanded="false"] .grp-caret { transform: rotate(-90deg); }
.grp-sum { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
@media (max-width: 760px) { .chips .fmenu { margin-left: 0; } .fmenu-pop { left: 0; right: auto; } }
.home-hello { margin: -6px 0 16px; color: var(--muted); }
.home-phases { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.home-phase { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow); border-top: 3px solid var(--brand); }
.home-phase.p2 { border-top-color: var(--accent); }
.home-phase h3 { margin: 0 0 4px; font-size: 14px; }
.home-phase .steps { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 13px; }
.home-phase .steps a { text-decoration: none; font-weight: 600; }
.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.home-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; min-width: 0; }
.home-card h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; font-size: 15px; }
.home-card h3 .badge { font-size: 13px; }
.home-card .hint { font-size: 12px; color: var(--muted); margin: 0 0 10px; }
.home-card .table-wrap { box-shadow: none; }
.home-card table.data th { position: static; }
.home-card .all { margin-top: 10px; text-align: right; }
.home-done { padding: 14px; text-align: center; color: var(--ok-text); background: var(--ok-soft); border-radius: 10px; font-weight: 600; }
.picker { position: relative; }
.picker-list { position: absolute; top: 100%; left: 0; right: 0; z-index: 20; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); max-height: 260px; overflow-y: auto; }
.picker-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.picker-item:last-child { border-bottom: 0; }
.picker-item:hover { background: var(--hover); }
.picker-empty { padding: 10px 12px; color: var(--muted); font-size: 13px; }
.proj-group { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 8px; }
.proj-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.proj-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); display: grid; gap: 6px; }
.proj-card.ended { opacity: .8; }
.proj-card .title { font-weight: 600; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.proj-card .title a { text-decoration: none; }
.proj-card .meta { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; font-size: 13px; }
.proj-card .meta span { color: var(--muted); }
.proj-card .meta strong { font-variant-numeric: tabular-nums; }
/* HQ-25: gom phụ lục — khung gợi ý gộp, thanh chọn phụ lục, dòng ô chọn trong hộp thoại */
.suggest-panel { border-left: 3px solid var(--warn, #d97706); margin-bottom: 12px; }
.suggest-panel h4 { margin: 0 0 4px; }
.sg-row { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); }
.sg-row .btn { flex: none; }
.group-bar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 0 0 8px; }
.group-bar label { display: inline-flex; gap: 6px; align-items: center; }
.check-row { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; }
a.badge { text-decoration: none; }
.btn.disabled { opacity: .5; cursor: default; pointer-events: none; }
@media (max-width: 600px) { .sg-row { flex-direction: column; } }
.rev-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 14px 0 8px; }
.rev-group h4 { margin: 0; font-size: 14px; }
@media (max-width: 900px) { .home-grid, .home-phases { grid-template-columns: 1fr; } }
a.btn { display: inline-flex; align-items: center; text-decoration: none; color: var(--ink); }
a.btn.primary, a.btn.mint { color: #fff; }
a.btn.mint { color: #2A1608; }
.kanban.six.four { grid-template-columns: repeat(4, minmax(220px, 1fr)); }
/* ---- HQ-19: việc hẹn (Sắp tới / Quá hạn), chấm việc kế tiếp trên thẻ Kanban / danh sách, khối Việc hẹn ở trang chủ ---- */
.act-due-list { display: grid; gap: 8px; margin-bottom: 14px; }
.act-due { border: 1px solid var(--line); border-left: 4px solid var(--warn); border-radius: 10px; padding: 8px 12px; background: var(--surface); }
.act-due.late { border-left-color: var(--err); background: var(--err-soft); }
.act-due-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.act-due-head .muted { font-size: 12px; }
.act-due-actions { margin-left: auto; display: inline-flex; gap: 6px; flex-wrap: wrap; }
.timeline-item.canceled { opacity: .65; }
.timeline-item.canceled strong { text-decoration: line-through; }
.chips.due-quick { margin: -4px 0 10px; }
.act-dot { display: inline-block; width: 12px; height: 12px; min-width: 12px; border-radius: 50%; border: 0; padding: 0; vertical-align: middle; background: var(--muted); opacity: .45; }
.act-dot.planned { background: var(--ok); opacity: 1; }
.act-dot.overdue { background: var(--err); opacity: 1; box-shadow: 0 0 0 3px var(--err-soft); }
button.act-dot { cursor: pointer; }
button.act-dot:hover, button.act-dot:focus-visible { opacity: 1; outline: 2px solid var(--brand); outline-offset: 2px; }
.kanban-title { display: flex; align-items: flex-start; gap: 6px; }
.kanban-title .act-dot { margin-top: 5px; margin-left: auto; }
.home-card.due { grid-column: 1 / -1; }
.home-card tr.late td { background: var(--err-soft); }
.home-card tr.late td:first-child { box-shadow: inset 4px 0 0 var(--err); }
.section-actions .btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* ---- Tìm kiếm toàn cục + menu tài khoản (HQ-21) ---- */
.gsearch { display: inline-flex; align-items: center; gap: 8px; min-width: 0; width: min(420px, 38vw); height: 36px; padding: 0 10px; margin-left: 10px; border: 1px solid var(--btn-border); border-radius: 10px; background: var(--surface); color: var(--muted); cursor: text; text-align: left; transition: border-color .12s, box-shadow .12s; }
.gsearch:hover, .gsearch:focus-visible { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); outline: none; }
.gsearch svg, .gs-head svg { width: 17px; height: 17px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.gsearch-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
kbd { display: inline-block; padding: 0 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--surface-2); color: var(--muted); font: 600 11px/1.6 var(--font); }
.gs-bg { position: fixed; inset: 0; z-index: 60; background: var(--overlay); display: flex; justify-content: center; align-items: flex-start; padding: 9vh 16px 16px; }
.gs { width: 100%; max-width: 680px; max-height: 78vh; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 24px 70px rgb(0 0 0 / .4); overflow: hidden; animation: fadein .15s ease both; }
.gs-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--muted); position: relative; }
.gs .gs-head input, .gs .gs-head input:focus { flex: 1; min-width: 0; border: 0; outline: 0; box-shadow: none; border-radius: 0; background: transparent; font-size: 16px; padding: 8px 0; min-height: 0; color: var(--ink); }
.gs-head:focus-within { color: var(--brand); }
.gs-bg.loading .gs-head::after { content: ""; position: absolute; left: 0; bottom: -1px; height: 2px; width: 40%; background: var(--accent); animation: gs-load 1s ease-in-out infinite; }
@keyframes gs-load { from { left: -40%; } to { left: 100%; } }
.gs-list { overflow-y: auto; padding: 6px 8px 10px; }
.gs-group + .gs-group { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 4px; }
.gs-group-head { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; color: var(--muted); padding: 8px 8px 4px; display: flex; align-items: center; gap: 6px; }
.gs-count { background: var(--surface-2); border-radius: 999px; padding: 0 7px; letter-spacing: 0; font-size: 11px; }
.gs-item { display: flex; flex-direction: column; gap: 1px; padding: 7px 10px; border-radius: 10px; text-decoration: none; color: var(--ink) !important; }
.gs-item.active { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }
.gs-main { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.gs-title { font-weight: 600; }
.gs-code { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.gs-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-item mark { background: rgb(240 190 90 / .35); color: inherit; border-radius: 3px; padding: 0 1px; }
.gs-more { font-size: 13px; font-weight: 600; color: var(--brand-dark) !important; }
:root[data-theme="dark"] .gs-more { color: var(--brand-dark) !important; }
.gs-hint, .gs-empty { padding: 14px 10px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.gs-empty { color: var(--ink); }
.gs-foot { display: flex; flex-wrap: wrap; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.gs-foot-tip { margin-left: auto; }
body.gs-open { overflow: hidden; }
.umenu { position: relative; flex: none; }
button.avatar { border: 0; padding: 0; cursor: pointer; }
button.avatar:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.umenu-pop { position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; z-index: 40; animation: fadein .12s ease both; }
.umenu-who { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-size: 13px; overflow-wrap: anywhere; }
.umenu-pop button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.umenu-pop button:hover, .umenu-pop button:focus-visible { background: var(--hover); outline: none; }
.umenu-pop button.danger { color: var(--err); }
@media (max-width: 1100px) { .topbar .who { display: none; } }
@media (max-width: 760px) {
  .topbar { gap: 8px; padding: 0 12px; }
  .topbar .tb-wide { display: none; }
  .gsearch { width: 38px; height: 38px; padding: 0; justify-content: center; margin-left: auto; cursor: pointer; }
  .gsearch-text, .gsearch-kbd { display: none; }
  .topbar .spacer { display: none; }
  .topbar .umenu { margin-left: auto; }   /* không có ô tìm toàn cục ⇒ nút tài khoản tự dạt phải */
  .avatar { width: 34px; height: 34px; }
  .gs-bg { padding: 0; }
  .gs { max-width: none; max-height: none; height: 100%; border-radius: 0; border: 0; }
  .gs-foot { display: none; }
  .gs-item { padding: 10px; }
}

/* ---- Dòng thời gian gộp / chatter (HQ-22) ---- */
.chatter-composer { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 16px; box-shadow: var(--shadow); }
.composer-box { position: relative; }
.chatter-composer textarea { width: 100%; resize: vertical; min-height: 54px; }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 6px; font-size: 12px; }
.mention-pop { position: absolute; left: 0; top: 100%; z-index: 30; min-width: 240px; max-width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; }
.mention-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 12px; cursor: pointer; }
.mention-item.active, .mention-item:hover { background: var(--brand-soft); }
.mention { color: var(--brand-dark); background: var(--brand-soft); border-radius: 5px; padding: 0 3px; font-weight: 600; }
:root[data-theme="dark"] .mention { color: var(--brand-dark); }
.tl { margin-left: 14px; }
.tl-item { position: relative; display: flex; gap: 10px; padding: 4px 0 14px 18px; }
.tl-item::before { display: none; }
.tl-icon { position: absolute; left: -13px; top: 4px; width: 24px; height: 24px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line); display: flex; align-items: center; justify-content: center; color: var(--muted); }
.tl-icon svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.kind-note > .tl-icon { border-color: var(--brand); color: var(--brand-dark); }
.kind-activity > .tl-icon { border-color: var(--ok); color: var(--ok-text); }
.kind-stage > .tl-icon { border-color: var(--warn); color: var(--warn); }
.kind-created > .tl-icon { border-color: var(--accent); color: var(--accent-text); }
.tl-body { flex: 1; min-width: 0; }
.tl-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.tl-head .muted, .tl-time { font-size: 12px; color: var(--muted); }
.tl-time { cursor: help; border-bottom: 1px dotted var(--line); }
.tl-actions { margin-left: auto; display: inline-flex; gap: 4px; }
.tl-note { margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.tl-item.pinned .tl-note { border-color: var(--brand); background: var(--brand-soft); }
.tl-changes { display: grid; gap: 2px; margin-top: 4px; font-size: 13px; }
.tl-change { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tl-field { color: var(--muted); min-width: 120px; }
.tl-old { text-decoration: line-through; color: var(--muted); }
.tl-new { font-weight: 600; }
.tl-more { text-align: center; margin: 4px 0 10px; }
@media (max-width: 760px) {
  .chatter-composer { position: sticky; top: 56px; z-index: 5; }
  .tl-field { min-width: 0; width: 100%; }
  .tl-actions { margin-left: 0; width: 100%; }
}
/* ---- HQ-26 người liên hệ: quá trình làm việc, chip vai trò trong dự án, khung "trùng" ---- */
.contact-sub { margin: -6px 0 12px; font-size: 15px; }
.copyable { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.copy-btn { padding: 1px 8px; min-height: 24px; font-size: 12px; }
.job-list { list-style: none; margin: 4px 0 0; padding: 0 0 0 6px; }
.job { position: relative; display: flex; gap: 12px; padding: 0 0 16px 0; }
.job::before { content: ""; position: absolute; left: 6px; top: 16px; bottom: 0; width: 2px; background: var(--line); }
.job:last-child::before { display: none; }
.job-dot { flex: 0 0 14px; height: 14px; margin-top: 3px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); position: relative; z-index: 1; }
.job.current .job-dot { border-color: var(--accent); background: var(--accent); }
.job-body { display: grid; gap: 3px; min-width: 0; }
.job-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.job-note { font-size: 13px; }
.job-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.role-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.role-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--brand-soft); color: var(--brand-dark); white-space: nowrap; }
.role-chip.role-decision_maker { background: var(--warn-soft); color: var(--warn); }
.role-chip.role-accounting { background: var(--ok-soft); color: var(--ok-text); }
.role-chip.role-other, .role-chip.role-technical { background: var(--surface-2); color: var(--muted); }
.role-chip button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 0 0 2px; }
.dup-box .dup-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.row-actions { display: inline-flex; flex-wrap: wrap; gap: 6px; }
dl.kv { display: grid; grid-template-columns: minmax(120px, 200px) 1fr; gap: 8px 16px; margin: 0 0 8px; }
dl.kv dt { color: var(--muted); font-size: 13px; }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 760px) { dl.kv { grid-template-columns: 1fr; gap: 2px; } dl.kv dd { margin-bottom: 8px; } }
/* HQ-68: ẩn "Đổi mật khẩu" với tài khoản tạo qua Lark (display của .btn / .umenu-pop button thắng thuộc tính hidden) */
.topbar [hidden] { display: none !important; }

/* ---- LEM-2: màn chờ duyệt / đặt mật khẩu (thẻ giữa trang), trang chủ + phân hệ sắp có, nội dung email ---- */
.center-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: var(--bg); }
.center-card { background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--lemon); border-radius: var(--radius); padding: 28px; width: 100%; max-width: 460px; }
.center-card h1 { font-size: 20px; margin: 16px 0 8px; }
.center-card .who-box { background: var(--surface-2); border-radius: 6px; padding: 10px 12px; margin: 14px 0; font-size: 13px; overflow-wrap: anywhere; }
.center-card .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.center-card ol { padding-left: 20px; margin: 8px 0 0; }
.center-card ol li { margin: 4px 0; }
.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--lemon); box-shadow: 0 0 0 3px var(--accent-soft); margin-right: 8px; vertical-align: middle; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }
.module-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.module-card h3 { margin: 0 0 4px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.module-card h3 svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.module-card p { margin: 0; font-size: 13px; color: var(--muted); }
.module-card .phase { display: inline-block; margin-top: 8px; font-size: 11px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.mail-body { white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.55 var(--font); background: var(--surface-2); border-radius: 6px; padding: 12px; max-height: 50vh; overflow: auto; margin: 0; }
.mail-list-title { font-size: 14px; margin: 16px 0 8px; }
#mfaRequired { margin-bottom: 14px; }
.sidenav a.later { color: var(--muted); }   /* phân hệ sắp có: mờ hơn mục thường nhưng vẫn đủ tương phản (bấm được) */
.sidenav a.later.active { color: var(--ink); }
/* màn cảm ứng (≤ 1024 px): vùng bấm thanh trên ≥ 44 px */
@media (max-width: 1024px) { .topbar .avatar, button.avatar { width: 44px; height: 44px; } .topbar .btn.small { min-height: 44px; min-width: 44px; } }
a.module-card { text-decoration: none; color: inherit; }
a.module-card:hover { border-color: var(--btn-border); background: var(--hover); }

/* ---- Phân hệ HR (LEM-3): focus bàn phím, trang chủ, thẻ chấm công, hồ sơ nhân sự, ngăn kéo chi tiết, bảng lương ---- */
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }   /* ô nhập đã có viền + bóng khi focus */
.tabs a:focus-visible, .chip:focus-visible { outline-offset: -2px; }
.btn.danger { background: var(--err); border-color: var(--err); color: var(--surface); font-weight: 600; }
.btn.danger:hover { background: var(--err); border-color: var(--err); filter: brightness(.95); }
a.chip { text-decoration: none; display: inline-flex; align-items: center; }
.path-scroll { overflow-x: auto; scrollbar-width: thin; }
.path-scroll .path { min-width: 760px; flex-wrap: nowrap; }
.path-scroll + .path-guide { margin-top: 4px; }
/* trang chủ */
#homeToday:not(:empty) { margin-bottom: 20px; }
.home-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 20px; }
.home-tile { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); color: var(--ink); text-decoration: none; }
a.home-tile { color: var(--ink); }
.home-tile:hover { background: var(--hover); border-color: var(--btn-border); }
.home-tile.warn { background: var(--warn-soft); }
.home-tile.warn .kpi-value { color: var(--warn); }
.home-tile .kpi-value { font-size: 22px; }
.home-tile-hint { font-size: 12px; color: var(--muted); }
.home-tiles .home-done { grid-column: 1 / -1; }
/* thẻ chấm công hôm nay */
.att-wide { grid-column: 1 / -1; margin: 0; }
.att-today .msg { margin: 0; }
.att-geo.ok { color: var(--ok-text); }
.att-geo.warn { color: var(--warn); }
.att-kpis { margin-bottom: 14px; }
.req-balance { margin-bottom: 12px; }
table.att-cal td:last-child { white-space: normal; min-width: 132px; }   /* lịch tháng: ghi chú xuống dòng thay vì đẩy bảng rộng */
table.att-cal .att-badges .badge { white-space: normal; }
/* hồ sơ nhân sự */
.filters .grow { flex: 2 1 240px; }
.filters .grow input { width: 100%; }
.list-count { margin: 0 0 6px; font-size: 13px; }
table.data td.nowrap, table.data .badge { white-space: nowrap; }
/* bộ lọc phụ: máy tính hiện thẳng trong hàng lọc; điện thoại thu vào nút "Bộ lọc khác" */
.more-filters { display: contents; }
.more-toggle { display: none; }
@media (max-width: 760px) {
  .more-toggle { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; flex: 1 1 100%; }
  .more-filters { display: none; }
  .more-filters.open { display: contents; }
}
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 14px; margin-bottom: 16px; }
.detail-grid dl.kv { grid-template-columns: minmax(96px, 38%) minmax(0, 1fr); }
.detail-grid .card { min-width: 0; }
.detail-grid .section-title, .card > .section-title:first-child { margin-top: 0; }
.page-head h1 .badge { vertical-align: middle; font-size: 13px; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.mask-hint { font-size: 12px; }
.pending-list { display: grid; gap: 12px; }
.pending-item { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 12px; align-items: end; }
.pending-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.pending-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; min-width: 0; }
.pending-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); flex: 1 1 180px; min-width: 0; }
.pending-form select { width: 100%; }
.copy-row { display: flex; gap: 8px; margin-top: 8px; }
.copy-row input { flex: 1; min-width: 0; }
/* ngăn kéo chi tiết (dòng lương…) */
.drawer-bg { position: fixed; inset: 0; z-index: 55; display: flex; justify-content: flex-end; background: var(--overlay); }
.drawer { width: min(560px, 100%); height: 100%; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: 0 12px 40px rgb(0 0 0 / .18); outline: none; animation: drawerin .2s ease-out both; }
@keyframes drawerin { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer header { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.drawer header h2 { flex: 1; min-width: 0; margin: 0; font-size: 17px; overflow-wrap: anywhere; }
.drawer header .btn { min-width: 44px; min-height: 44px; font-size: 20px; line-height: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px 18px 28px; }
.drawer-body .section-title { margin-top: 18px; }
.drawer-actions { margin-top: 18px; }
body.drawer-open { overflow: hidden; }
.drawer-bg ~ .modal-bg { z-index: 56; }   /* hộp xác nhận mở TỪ ngăn kéo (bỏ điều chỉnh ô, xoá cột…) nằm trên ngăn kéo, không bị che */
.line-dl { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 16px; margin: 0; }
.line-dl dt { color: var(--muted); font-size: 13px; }
.line-dl dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.line-dl .total { font-weight: 700; color: var(--ink); border-top: 1px solid var(--line); padding-top: 6px; }
@media (max-width: 760px) {
  .pending-item, .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .home-tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .home-tile .kpi-value { font-size: 19px; }
  .line-dl dd { white-space: normal; }
}
/* màn cảm ứng: vùng bấm ≥ 44 px cho nút, tab, chip */
@media (pointer: coarse) {
  .btn, .chip, .tabs a { min-height: 44px; }
  .tabs a { display: inline-flex; align-items: center; }
}
table.data .link-btn { text-align: left; font-size: inherit; }
.req-cards { display: none; }
.req-card { display: grid; gap: 6px; padding: 14px; }
.req-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.req-card-reason { font-size: 13px; overflow-wrap: anywhere; }
@media (max-width: 760px) {
  #reqBody .table-wrap:has(table) { display: none; }
  #reqBody .req-cards { display: grid; gap: 10px; }
}
/* thẻ "của tôi" (bảng công / phiếu lương của nhân viên) */
.my-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
#tsList > .my-card { max-width: 520px; }
.my-card { display: grid; gap: 6px; }
.my-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.my-card-num { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.my-card-num .muted { font-size: 13px; font-weight: 400; }

/* === LEM-4 cổng nhân viên === */
/* views/portal.js — #/me "Của tôi" + dải thông báo APP_BANNER. Chỉ dùng biến màu ở :root. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.app-banner { background: var(--warn-soft); color: var(--ink); border-bottom: 1px solid var(--warn); text-align: center; font-size: 12px; font-weight: 600;
  line-height: 1.45; padding: 4px 16px; letter-spacing: .01em; overflow-wrap: anywhere; }
@media (min-width: 761px) {
  body.has-banner { display: flex; flex-direction: column; }
  body.has-banner #app { flex: 1; min-height: 0; height: auto; overflow-y: auto; }
  body.has-banner .login-wrap, body.has-banner .center-wrap { min-height: 100%; }
}
.portal-head { flex-direction: column; align-items: flex-start; gap: 2px; }
.portal-head h1 { flex: none; }
.portal-who { margin: 0; overflow-wrap: anywhere; }
.portal-tabs { margin-bottom: 14px; }
.portal-monthbar { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; }
.portal-monthbar select { min-width: 0; flex: 0 1 200px; font-weight: 600; }
.portal-paybar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 4px; }
.portal-paybar .portal-monthbar { margin: 0 0 10px; }
.portal-paybar > .btn { margin-bottom: 10px; }
.portal-kpis { margin-bottom: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.portal-kpis .kpi-group { padding: 12px 14px; }
.portal-kpis .kpi-value { font-size: 21px; }
.portal-kpis .kpi-value small { font-size: 13px; font-weight: 400; color: var(--muted); }
.portal-note { margin: 0 0 14px; font-size: 13px; }
.portal-small { font-size: 12px; }
.portal-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 14px; }
.portal-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.portal-wrap { white-space: normal !important; min-width: 120px; }
.portal-nowrap { white-space: nowrap; }
#portalToday .att-today { margin-bottom: 14px; }
/* bảng ngày (máy tính) / thẻ ngày (điện thoại) */
table.portal-days th[scope="row"] { font-weight: 400; white-space: nowrap; background: none; position: static; font-size: 14px; color: var(--ink); }
table.portal-days .portal-date { font-weight: 700; font-variant-numeric: tabular-nums; }
table.portal-days .portal-units { font-weight: 700; }
table.portal-days tr.portal-off td, table.portal-days tr.portal-off th { background: var(--surface-2); }
table.portal-days tr.portal-future td, table.portal-days tr.portal-future th[scope="row"] { color: var(--muted); }
table.portal-days tr.portal-today th[scope="row"] { box-shadow: inset 3px 0 0 var(--lemon); }
.portal-reason { color: var(--err); font-size: 13px; margin: 0; }
.portal-req { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; padding: 3px 0; color: var(--ink); text-decoration: none; font-size: 13px; }
.portal-req > span:first-child { text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--btn-border); }
.portal-req:hover > span:first-child { text-decoration-color: currentColor; }
.portal-req + .portal-req { margin-left: 8px; }
.portal-day-cards { display: none; list-style: none; margin: 0; padding: 0; }
.portal-day-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: grid; gap: 6px; min-width: 0; }
.portal-day-card + .portal-day-card { margin-top: 8px; }
.portal-day-card.portal-today { border-left: 3px solid var(--lemon); }
.portal-day-card.portal-zero { border-color: var(--err); }
.portal-day-empty { display: flex; justify-content: space-between; gap: 8px; padding: 6px 12px; background: var(--surface-2); font-size: 13px; }
.portal-day-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.portal-day-units { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.portal-day-units small { font-size: 12px; font-weight: 400; color: var(--muted); }
.portal-day-times { display: flex; flex-wrap: wrap; gap: 4px 16px; font-variant-numeric: tabular-nums; color: var(--muted); }
.portal-day-times b { color: var(--ink); }
.portal-day-tags { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; margin: 0; }
.portal-day-reqs { display: grid; gap: 2px; }
.portal-day-reqs .portal-req + .portal-req { margin-left: 0; }
@media (max-width: 900px) {   /* bảng 10 cột cần ~900 px: máy tính bảng dọc cũng dùng thẻ */
  .portal-days-table { display: none; }
  .portal-day-cards { display: block; }
}
@media (pointer: coarse) {
  .portal-monthbar .btn.icon { min-width: 44px; min-height: 44px; }
  .portal-monthbar select { min-height: 44px; }
}
/* bảng công */
.portal-ts-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); gap: 14px; align-items: start; }
.portal-ts-grid > * { min-width: 0; }
.portal-ts-side { display: grid; gap: 14px; }
.portal-comps .section-title, .portal-totals .section-title { margin-top: 0; }
.portal-comp { border-top: 1px solid var(--line); }
.portal-comp-sum { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 10px 0; cursor: default; list-style: none; }
details.portal-comp > .portal-comp-sum { cursor: pointer; }
details.portal-comp > .portal-comp-sum::-webkit-details-marker { display: none; }
details.portal-comp > .portal-comp-sum::before { content: "▸"; color: var(--muted); width: 12px; flex: none; font-size: 15px; line-height: 1; transition: transform .12s; }
details.portal-comp[open] > .portal-comp-sum::before { transform: rotate(90deg); }
.portal-comp-flat .portal-comp-sum { padding-left: 24px; }
.portal-comp-label { flex: 1 1 180px; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.portal-comp-vals { display: flex; gap: 14px; font-variant-numeric: tabular-nums; }
.portal-comp-vals small { color: var(--muted); font-size: 12px; }
.portal-comp-count { font-size: 12px; }
.portal-comp-reason { margin: 0 0 8px 24px; font-size: 13px; overflow-wrap: anywhere; }
.portal-scroll { overflow-x: auto; margin: 0 0 12px 24px; border: 1px solid var(--line); border-radius: var(--radius); }
.portal-total-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.portal-total-num { font-variant-numeric: tabular-nums; font-size: 16px; }
.portal-cap { flex-basis: 100%; font-size: 13px; color: var(--warn); }
.portal-cap.muted { color: var(--muted); }
.portal-grand { border-bottom: 0; font-weight: 700; }
.portal-grand .portal-total-num { font-size: 20px; }
.portal-confirm-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.portal-confirm p { margin: 6px 0; overflow-wrap: anywhere; }
.portal-confirm .portal-actions { margin-top: 10px; }
/* lương */
.portal-pay-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.portal-pay-card { display: grid; gap: 2px; color: var(--ink); text-decoration: none; min-width: 0; }
.portal-pay-card:hover { background: var(--hover); border-color: var(--btn-border); }
.portal-pay-month { font-weight: 700; margin-bottom: 4px; }
.portal-pay-net { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-bottom: 6px; overflow-wrap: anywhere; }
.portal-slip-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.portal-slip-head h2 { margin: 0 0 2px; font-size: 18px; }
.portal-slip-head p { margin: 0 0 6px; overflow-wrap: anywhere; }
.portal-groups { display: grid; gap: 14px; max-width: 920px; margin-bottom: 14px; }
.portal-group .section-title { margin-top: 0; }
.portal-group-net { border-top: 3px solid var(--lemon); }
.portal-xlist { list-style: none; margin: 0; padding: 0; }
.portal-x { padding: 9px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.portal-x:last-child { border-bottom: 0; }
.portal-x-head { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 12px; flex-wrap: wrap; }
.portal-x-label { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.portal-col { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.portal-x-val { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; margin-left: auto; }
.portal-rule { font-size: 12px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.portal-formula { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; margin-top: 2px; }
.portal-x-note { font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.portal-x-diff { box-shadow: inset 3px 0 0 var(--warn); padding-left: 10px; }
.portal-group-total { display: flex; justify-content: space-between; gap: 12px; padding-top: 10px; margin-top: 4px; border-top: 2px solid var(--line); font-variant-numeric: tabular-nums; }
.portal-group-total b { font-size: 17px; }
.portal-unlinked { max-width: 640px; }
.portal-unlinked h2 { margin-top: 0; font-size: 18px; }
.portal-unlinked ol { padding-left: 20px; }
@media (max-width: 900px) {
  .portal-ts-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .portal-kpis { grid-template-columns: 1fr 1fr; }
  .portal-kpis .kpi-value { font-size: 18px; }
  .portal-scroll { margin-left: 0; }
  .portal-comp-reason { margin-left: 0; }
  .portal-pay-list { grid-template-columns: minmax(0, 1fr); }
  .portal-tabs a { padding-left: 9px; padding-right: 9px; }
}
@media (max-width: 400px) { .portal-tabs a { padding-left: 6px; padding-right: 6px; font-size: 13px; } }   /* 4 tab vừa 360 px */
#portalSlip > * { max-width: 920px; }

/* === LEM-5 cấu hình lương === */
/* Cài đặt → Cấu hình lương (views/hr_payroll_config.js): tham số luật, mẫu bảng lương + trình soạn công thức, gán mẫu, chạy thử & so sánh.
   Chỉ dùng biến màu; bảng rộng cuộn trong khung riêng, cột nhân viên dính trái. */
.pc input[type=month], .modal input[type=month], .pc-coled input[type=text], .pc-coled input:not([type]) {
  border: 1px solid var(--btn-border); border-radius: 6px; padding: 7px 11px; min-height: 36px; background: var(--surface); color: var(--ink); min-width: 0; }
.modal .field[hidden], .pc-coled .field[hidden], .pc-coled label[hidden], .pc-ac[hidden] { display: none; }
.pc-intro { margin: -6px 0 10px; max-width: 900px; }
.pc-subtabs { margin-bottom: 14px; }
.pc-subtabs .chip { text-decoration: none; display: inline-flex; align-items: center; }
.pc-ro { max-width: 900px; }
.pc-h2 { font-size: 17px; margin: 0; font-weight: 700; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.pc-h3 { font-size: 15px; margin: 18px 0 8px; }
.pc-sub { margin: 4px 0 0; max-width: 820px; }
.pc-small { font-size: 12px; }
.pc-hint { font-size: 12px; color: var(--muted); }
.pc-basis { font-size: 12px; color: var(--muted); font-style: italic; }
.pc-back { margin: 0 0 8px; }
.pc-back a { color: var(--muted); text-decoration: none; }
.pc-back a:hover { color: var(--ink); text-decoration: underline; }
.pc-meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 14px; max-width: 900px; }
.pc-meta p { grid-column: 1 / -1; margin: 0 0 10px; }
.pc-search { min-width: 0; flex: 1 1 200px; max-width: 320px; }
.pc-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.pc-inline-field { margin: 0; }
.pc-chipline { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.pc-req { font-size: 11px; color: var(--accent-text); border: 1px solid var(--accent-dark); border-radius: 4px; padding: 0 4px; white-space: nowrap; }
.pc-okline { margin: 6px 0 0; color: var(--ok-text); font-size: 13px; }
.pc-errtxt { color: var(--err); font-weight: 700; }
.pc-cov-head { margin-top: 26px; align-items: flex-end; flex-wrap: wrap; }

/* bước vòng đời: Sửa nháp → Chạy thử → Áp dụng */
.pc-steps { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 10px 0 14px; }
.pc-steps li { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px 5px 6px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; color: var(--muted); background: var(--surface); }
.pc-steps li span { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 700; }
.pc-steps li.done { color: var(--ok-text); border-color: var(--ok-soft); }
.pc-steps li.done span { background: var(--ok-soft); color: var(--ok-text); }
.pc-steps li.current { color: var(--ink); border-color: var(--brand); font-weight: 600; }
.pc-steps li.current span { background: var(--brand); color: var(--surface); }

/* bộ tham số */
.pc-group { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 12px 16px 6px; margin: 0 0 14px; min-width: 0; }
.pc-group legend { font-weight: 700; padding: 0 6px; font-size: 15px; }
.pc-group > .pc-hint { margin: 0 0 10px; }
.pc-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 18px; }
.pc-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; min-width: 0; }
.pc-field.wide { grid-column: 1 / -1; }
.pc-field > label { font-size: 13px; color: var(--muted); display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.pc-input { display: flex; align-items: center; gap: 6px; }
.pc-input input { flex: 1; min-width: 0; text-align: right; font-variant-numeric: tabular-nums; }
.pc-unit { color: var(--muted); font-size: 13px; min-width: 30px; }
.pc-val { font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.pc-brackets { max-width: 620px; margin-bottom: 8px; }
.pc-brackets input { width: 100%; min-width: 90px; text-align: right; font-variant-numeric: tabular-nums; }
.pc-actionbar { position: sticky; bottom: 0; z-index: 4; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 0; background: var(--bg); border-top: 1px solid var(--line); }
.pc-actionbar:empty { display: none; }
.pc-preset { margin-bottom: 12px; padding: 12px 14px; box-shadow: none; }
.pc-preset h3 { margin: 0 0 6px; font-size: 15px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pc-preset .kv { grid-template-columns: minmax(0, 1fr) auto; }

/* trình soạn mẫu */
.pc-formula { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.pc-fcell { display: inline-block; max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.pc-vbar { margin-top: 4px; }
.pc-codebtn { font-size: 13px; min-height: 28px; text-align: left; }
.pc-issues { margin: 6px 0 0; padding-left: 18px; }
.pc-issues li.warn { color: var(--ink); }
.pc-snip { display: block; margin-top: 4px; padding: 4px 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; white-space: pre-wrap; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; color: var(--ink); }
.pc-snip mark { background: var(--err-soft); color: var(--err); outline: 1px solid var(--err); border-radius: 2px; }
.pc-coled textarea { width: 100%; min-height: 110px; resize: vertical; line-height: 1.5; }
.pc-checks { justify-content: flex-end; }
.pc-checks label { display: flex; align-items: center; gap: 7px; color: var(--ink); font-size: 14px; min-height: 32px; }
.pc-colbar { margin: 16px 0 0; }
.pc-ac-wrap { position: relative; }
.pc-ac { position: absolute; left: 0; right: 0; top: 100%; z-index: 6; margin: 2px 0 0; padding: 4px 0; list-style: none; max-height: 260px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--btn-border); border-radius: 6px; box-shadow: var(--shadow); }
.pc-ac li[role=option] { display: flex; flex-direction: column; gap: 1px; padding: 6px 10px; cursor: pointer; }
.pc-ac li[role=option] code { font-size: 13px; color: var(--ink); }
.pc-ac li[aria-selected=true], .pc-ac li[role=option]:hover { background: var(--brand-soft); }
.pc-ac-lbl { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.pc-ac-grp { padding: 6px 10px 2px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.pc-cat { margin-top: 6px; }
.pc-cat summary { cursor: pointer; font-size: 13px; color: var(--muted); min-height: 32px; display: flex; align-items: center; }
.pc-catgrp h4 { margin: 10px 0 4px; font-size: 12px; color: var(--muted); }
.pc-catgrp > div { display: flex; flex-wrap: wrap; gap: 4px; }
.pc-tok { border: 1px solid var(--btn-border); background: var(--surface-2); color: var(--ink); border-radius: 4px; padding: 2px 7px; font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; cursor: pointer; min-height: 26px; }
.pc-tok:hover:not(:disabled) { border-color: var(--brand); }
.pc-tok:disabled { cursor: default; opacity: .7; }
.pc-test { margin-top: 20px; }
.pc-test h3 { margin: 0; font-size: 15px; }
.pc-test-form { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 0 12px; margin-top: 10px; align-items: end; }
.pc-test-form .field select, .pc-test-form .field input { width: 100%; }
.pc-test-form .field select#pcTEmp { margin-top: 4px; }
.pc-test-go { justify-content: flex-end; }
.pc-test-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin: 6px 0 8px; }
.pc-steplist { margin: 6px 0 0; padding-left: 18px; font-size: 12px; }
.pc-steplist li { overflow-wrap: anywhere; white-space: normal; }
.pc-testtbl td { white-space: normal; }
.pc-testtbl th.num, .pc-grid th.num { text-align: right; }
.pc-inputs { margin-top: 10px; }
.pc-inputs summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.pc-inputs .kv { grid-template-columns: minmax(0, 220px) minmax(0, 1fr); margin-top: 8px; font-size: 13px; }

/* chạy thử & so sánh */
.pc-kpis { margin: 10px 0 12px; }
.pc-kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; border-left: 3px solid var(--line); }
.pc-kpi.ok { border-left-color: var(--ok); }
.pc-kpi.warn { border-left-color: var(--warn); }
.pc-kpi.err { border-left-color: var(--err); }
.pc-totals { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-bottom: 14px; }
.pc-total { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; font-variant-numeric: tabular-nums; min-width: 0; }
.pc-total-row { overflow-wrap: anywhere; margin: 2px 0; }
.pc-total-row strong { font-size: 17px; }
.pc-gridbar { align-items: center; }
.pc-gridbar .pc-inline { min-width: 0; max-width: 100%; }
.pc-gridbar select { min-width: 0; max-width: 100%; }
.pc-grid { max-height: 70vh; overflow: auto; }
.pc-grid table.data td, .pc-grid table.data th { white-space: nowrap; }
.pc-grid thead th { z-index: 2; }
.pc-grid .pc-stick { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--line); text-align: left; color: var(--ink); font-size: 13px; }
.pc-grid thead .pc-stick { z-index: 3; background: var(--surface-2); color: var(--muted); }
.pc-thl { font-weight: 400; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
table.data td.pc-diff, table.data tr.pc-diff td, .pc-total.pc-diff { background: var(--warn-soft); }
table.data td.pc-err-cell, table.data tr.pc-err-row td { background: var(--err-soft); }
table.data td.pc-diff .pc-small { color: var(--ink); }

@media (max-width: 760px) {
  .pc input, .pc select, .pc textarea, .pc-coled input, .pc-coled select, .pc-coled textarea { font-size: 16px; }   /* iOS không phóng to khi gõ */
  .pc-fields { grid-template-columns: minmax(0, 1fr); }
  .pc-test-form { grid-template-columns: minmax(0, 1fr); }
  .pc-search { max-width: none; }
  .pc-fcell { max-width: 220px; }
  .pc-actionbar .pc-hint { flex-basis: 100%; }
  .pc .section-actions { flex-wrap: wrap; }
  .pc-preset .kv { grid-template-columns: minmax(0, 1fr); }
}
/* LEM-5: ô HR điều chỉnh trong ngăn kéo dòng lương */
.ov-list { list-style: none; padding: 0; margin: 0 0 12px; }
.ov-list li { padding: 8px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.ov-list li .btn { margin-top: 6px; }

/* (LEM-9) Sơ đồ tổ chức — cây đơn vị lồng nhau; thụt lề theo cấp, viền trái theo loại đơn vị */
.org-tree { display: grid; gap: 10px; }
.org-unit { border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 10px; background: var(--surface); }
.org-unit > summary { cursor: pointer; padding: 10px 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; list-style: none; }
.org-unit > summary::-webkit-details-marker { display: none; }
.org-unit > summary::before { content: "▸"; color: var(--muted); }
.org-unit[open] > summary::before { content: "▾"; }
.org-unit > summary .btn { margin-left: auto; }
.org-body { padding: 0 12px 12px 18px; display: grid; gap: 10px; }
.org-head { font-size: 14px; }
.org-kind { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.org-company, .org-division { border-left-color: var(--ink); }
.org-bod, .org-department { border-left-color: var(--brand); }
.org-team, .org-studio { border-left-color: var(--line); }
.org-off { opacity: .6; }
.org-members td, .org-members th { padding: 7px 10px; }
.org-pending { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
@media (max-width: 640px) { .org-body { padding: 0 8px 10px 8px; } }
