/* ZAFAGO CRM — giao diện dashboard hiện đại (dark mặc định + 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. Đổi theme: <html data-theme="dark|light">. */
:root {
  --brand: #5B5BD6;
  --brand-dark: #4545B5;
  --brand-soft: #ECECFF;
  --accent: #16A394;
  --accent-dark: #087F74;
  --accent-text: #087369;
  --accent-soft: #E4F7F4;
  --brand-gradient: linear-gradient(120deg, var(--brand) 0%, #8585E8 48%, #54C9BD 72%, var(--accent) 100%);
  --ink: #141A2E;
  --muted: #5A6382;
  --line: #E1E5EF;
  --bg: #F4F6FB;
  --surface: #FFFFFF;
  --surface-2: #EEF1F8;
  --hover: #F7F8FC;
  --ok: #1AA260;
  --ok-soft: #E6F6EE;
  --ok-text: #127A47;
  --warn: #B7791F;
  --warn-soft: #FEF6E7;
  --err: #C93A1D;
  --err-soft: #FDECE8;
  --btn-border: #C8CEDD;
  --soon: #A0A6BC;
  --glow: radial-gradient(60rem 28rem at 8% -8%, rgb(91 91 214 / .11), transparent 60%), radial-gradient(50rem 26rem at 96% -6%, rgb(22 163 148 / .12), transparent 60%);
  --shadow: 0 6px 24px rgb(20 26 46 / .08);
  --overlay: rgb(20 26 46 / .45);
  --glass: rgb(255 255 255 / .75);
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --brand-soft: rgb(91 91 214 / .2);
  --accent-soft: rgb(22 163 148 / .16);
  --accent-text: #5FE3D6;
  --brand-dark: #A7A7FF;
  --ink: #E8ECFA;
  --muted: #98A3C4;
  --line: rgb(255 255 255 / .09);
  --bg: #0A0F1E;
  --surface: #111933;
  --surface-2: #172044;
  --hover: #162043;
  --ok: #4ADE80;
  --ok-soft: rgb(74 222 128 / .13);
  --ok-text: #6EE7A0;
  --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: #5E6A8E;
  --glow: radial-gradient(60rem 28rem at 8% -8%, rgb(91 91 214 / .24), transparent 60%), radial-gradient(50rem 26rem at 96% -6%, rgb(22 163 148 / .18), transparent 60%);
  --shadow: 0 10px 34px rgb(0 0 0 / .4);
  --overlay: rgb(3 6 16 / .65);
  --glass: rgb(17 25 51 / .72);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 var(--font); color: var(--ink); background: var(--glow), var(--bg); background-repeat: no-repeat; background-attachment: fixed; 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(--accent-text); }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.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: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background: radial-gradient(40rem 26rem at 20% 15%, rgb(91 91 214 / .32), transparent 62%), radial-gradient(38rem 26rem at 82% 85%, rgb(22 163 148 / .28), transparent 62%), var(--bg); }
.login-card { background: var(--glass); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 32px; width: 100%; max-width: 400px; }
.login-card .logo { font-size: 30px; }
.login-card .btn.primary { background: linear-gradient(100deg, var(--brand), #7474E5); box-shadow: 0 6px 20px rgb(91 91 214 / .35); height: 40px; }
.logo { font-weight: 800; font-size: 24px; letter-spacing: .02em; margin: 0; }
.logo .z { color: var(--brand); }
.logo .g { color: var(--accent-dark); }
:root[data-theme="dark"] .logo .g { color: var(--accent); }

/* ---- Khung ứng dụng ---- */
.topbar { height: 56px; display: flex; align-items: center; gap: 14px; padding: 0 18px; background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--brand-gradient); opacity: .85; }
.topbar .logo { font-size: 19px; }
.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: linear-gradient(135deg, var(--brand), #7A5CFA 60%, var(--accent-dark)); flex: none; }
.layout { display: flex; min-height: calc(100vh - 56px); }
.sidenav { width: 224px; flex-shrink: 0; background: var(--glass); border-right: 1px solid var(--line); padding: 10px 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: 10px; 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: .85; }
.sidenav a:hover { background: var(--hover); }
.sidenav a.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.sidenav a.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--brand); }
.sidenav a.soon { color: var(--soon); pointer-events: none; }
.navtoggle { width: 100%; justify-content: flex-start; margin-bottom: 4px; }
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; letter-spacing: -.01em; }

/* ---- 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: 10px; cursor: pointer; transition: border-color .12s, background .12s, transform .12s, box-shadow .12s; }
.btn:hover { border-color: var(--accent-dark); background: var(--hover); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #6B6BE0; border-color: #6B6BE0; box-shadow: 0 6px 18px rgb(91 91 214 / .35); }
.btn.mint { background: var(--accent); border-color: var(--accent); color: #071F1D; 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: 10px; padding: 7px 11px; min-height: 36px; background: var(--surface-2); min-width: 0; transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-dark); box-shadow: 0 0 0 3px rgb(22 163 148 / .25); }
.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(--brand); }
.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(--brand); }
.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: 11px; text-transform: uppercase; letter-spacing: .06em; 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; }
.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 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.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: 10px; 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(--accent-soft); color: var(--accent-text); }

.modal-bg { position: fixed; inset: 0; background: var(--overlay); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); 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: 18px; width: 100%; max-width: 560px; box-shadow: 0 24px 70px rgb(0 0 0 / .4); 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: 12px; color: #fff; background: #1E2A52; 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: #B33A24; }

.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:hover { transform: translateY(-2px); }
.kpi-group.total { border-top-color: transparent; border-image: var(--brand-gradient) 1; border-image-slice: 1 0 0 0; }
.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); text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 24px; font-weight: 800; 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, .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; }
  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; }
.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: 10px; padding: 7px 11px; min-height: 36px; background: var(--surface-2); 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(--accent-soft); color: var(--accent-text); }
.path-step.current { background: var(--brand); color: #fff; }
.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-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: #071F1D; }
.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); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); 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(--brand-gradient); 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(--accent-text) !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; }
  .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(--accent-text); }
.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; } }
