/* Nice Life CRM — hệ thống thiết kế (phương án A)
   Bố cục: menu trái có dải màu hồng → tím trên máy tính, thanh tab dưới trên điện thoại.
   Nền xám tím rất nhạt, khối trắng bo góc lớn, thẻ chỉ số màu chuyển, bảng có tiêu đề nền tối. */
:root {
  --bg: #f4f5fb;
  --surface: #ffffff;
  --surface-2: #f1f2f8;
  --ink: #1f2140;
  --muted: #5c5f7e;
  --line: #e3e4ef;
  --accent: #5f37df;
  --accent-soft: #f1ecff;
  --accent-ink: #ffffff;
  --g-from: #d6336c;
  --g-to: #6a3de8;
  --grad: linear-gradient(120deg, var(--g-from), var(--g-to));
  --head: #23253f;
  --head-ink: #ffffff;
  --oak: #a3134a;
  --oak-soft: #fde7ef;
  --ok: #1e6b3a;
  --ok-soft: #e6f6ec;
  --warn: #8a4b00;
  --warn-soft: #fff1db;
  --bad: #b42318;
  --bad-soft: #fde8e6;
  --shadow: 0 1px 2px rgba(31, 33, 64, .06), 0 8px 24px rgba(31, 33, 64, .05);
  --font-ui: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r: 18px;
  --r-sm: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14152a; --surface: #1d1f38; --surface-2: #272a48; --ink: #ececf8; --muted: #a3a6c4; --line: #33365a;
    --accent: #a88bff; --accent-soft: #2e2752; --accent-ink: #14152a; --head: #0f1024; --head-ink: #ececf8;
    --oak: #ff8fb8; --oak-soft: #3d2033;
    --ok: #6fd39a; --ok-soft: #1b3528; --warn: #f2b964; --warn-soft: #3a2e1b; --bad: #ff8a80; --bad-soft: #3d2222;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14152a; --surface: #1d1f38; --surface-2: #272a48; --ink: #ececf8; --muted: #a3a6c4; --line: #33365a;
  --accent: #a88bff; --accent-soft: #2e2752; --accent-ink: #14152a; --head: #0f1024; --head-ink: #ececf8;
  --oak: #ff8fb8; --oak-soft: #3d2033;
  --ok: #6fd39a; --ok-soft: #1b3528; --warn: #f2b964; --warn-soft: #3a2e1b; --bad: #ff8a80; --bad-soft: #3d2222;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font-ui); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2 { margin: 0; text-wrap: balance; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: var(--font-mono); font-size: .92em; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.txt-bad { color: var(--bad); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Khung ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100%; }
.side { position: sticky; top: env(safe-area-inset-top, 0px); height: 100vh; display: flex; flex-direction: column; gap: 20px; padding: 20px 14px; border-right: 1px solid var(--line); background: var(--surface); }
.brand { display: flex; align-items: center; gap: 10px; font: 600 17px/1 var(--font-display); letter-spacing: -.01em; }
.brand em { font-style: normal; font: 600 11px/1 var(--font-ui); letter-spacing: .12em; color: var(--muted); padding-top: 3px; }
.brand-mark { width: 22px; height: 22px; border-radius: 4px; background:
  repeating-linear-gradient(90deg, transparent 0 3px, color-mix(in srgb, var(--accent-ink) 22%, transparent) 3px 4px), var(--accent); }
.brand-lg { font-size: 26px; }
.brand-lg .brand-mark { width: 30px; height: 30px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; border: 0; border-radius: var(--r-sm); background: none; color: var(--muted); cursor: pointer; text-align: left; font-weight: 500; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-on, .nav-on:hover { background: var(--accent-soft); color: var(--accent); }
.side-foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--line); }
.me { display: flex; flex-direction: column; }
.me span { color: var(--muted); font-size: 12px; }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; display: flex; align-items: center; gap: 12px; min-height: 56px;
  padding-block: 8px; padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
.brand-top { display: none; }
.demo-tag { font-size: 12px; color: var(--oak); background: var(--oak-soft); padding: 3px 10px; border-radius: 99px; font-weight: 500; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.content { width: 100%; max-width: 1240px; padding-block: 24px 48px; padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 18px; }
.tabbar { display: none; }
.boot { display: grid; place-items: center; height: 100%; color: var(--muted); }

/* ---------- Đầu trang ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; }
.page-head-text { min-width: 0; }
.page-head h1 { font: 600 28px/1.15 var(--font-display); letter-spacing: -.015em; }
.page-sub { margin: 6px 0 0; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.crumb { align-self: flex-start; border: 0; background: none; color: var(--muted); padding: 0; cursor: pointer; margin-bottom: -8px; }
.crumb:hover { color: var(--accent); }

/* ---------- Thành phần ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 16px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-sm { min-height: 30px; padding: 0 11px; font-size: 13px; }
.full { width: 100%; }
.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border: 0; border-radius: var(--r-sm); background: none; color: var(--muted); cursor: pointer; font-size: 20px; line-height: 1; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.linkish { border: 0; background: none; padding: 0; color: inherit; cursor: pointer; text-align: left; font: inherit; }
.linkish:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.note .linkish { color: var(--accent); margin-left: 6px; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-oak { background: var(--oak-soft); color: var(--oak); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; min-width: 0; }
.panel-attn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); background: color-mix(in srgb, var(--warn-soft) 40%, var(--surface)); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel h2, .side-title { font-size: 15px; font-weight: 600; }
.side-title { margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.note { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.note-warn { color: var(--warn); }
.note-bad { color: var(--bad); }
.empty { padding: 28px 12px; text-align: center; color: var(--muted); }
.empty-bad { color: var(--bad); }
.cell-sub { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.big-num { font-size: 24px; font-weight: 600; margin: 0; color: var(--oak); }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.kpi-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.kpi-value { font: 600 26px/1.2 var(--font-display); font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--muted); }
.kpi-bad { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.kpi-bad .kpi-sub { color: var(--bad); font-weight: 600; }

/* Thanh ngang */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 92px minmax(0, 1fr) 64px; align-items: center; gap: 10px; }
.bar-label { color: var(--muted); font-size: 13px; }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 99px; min-width: 2px; }
.bar-oak { background: var(--oak); }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; flex: 1; min-width: 60px; }
.progress-bar { height: 100%; border-radius: 99px; }
.progress-accent { background: var(--accent); } .progress-bad { background: var(--bad); } .progress-oak { background: var(--oak); } .progress-ok { background: var(--ok); }

.status-strip { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1px; background: var(--line); border-radius: var(--r-sm); overflow: hidden; }
.status-cell { background: var(--surface); padding: 12px 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.status-cell strong { font: 600 22px/1 var(--font-display); }
.status-cell span { font-size: 11px; color: var(--muted); }

/* Danh sách dòng */
.rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row-stack { flex-direction: column; align-items: stretch; }
.row-main { min-width: 0; }
.row-sub { display: block; color: var(--muted); font-size: 12px; }
.row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.row-meter { display: flex; align-items: center; gap: 10px; min-width: 140px; font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 600; }

/* Bảng */
.table-wrap { overflow-x: auto; min-width: 0; }
.table { width: 100%; min-width: 600px; border-collapse: collapse; font-size: 13.5px; }
.table-tight { min-width: 0; }
.table th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th.num { text-align: right; }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table-click tbody tr { cursor: pointer; }
.table-click tbody tr:hover td { background: var(--surface-2); }
.table-tight td, .table-tight th { padding: 7px 6px; }
.cell-clip { max-width: 280px; }
.table-edit td { padding: 6px 4px; vertical-align: middle; }
.table-edit input, .table-edit select { width: 100%; min-width: 0; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.table-edit td:first-child input { min-width: 140px; }
.table-edit select { min-width: 150px; }
.table-edit td:nth-child(2) select { min-width: 220px; }
.dims { display: flex; align-items: center; gap: 3px; }
.dims input { width: 62px; text-align: right; font-family: var(--font-mono); font-size: 12.5px; }
.dims span { color: var(--muted); }
.w-qty { width: 60px !important; text-align: right; }
.w-price { width: 110px !important; text-align: right; font-family: var(--font-mono); font-size: 12.5px; }

/* Biểu mẫu */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field-hint { font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea, .search, .note-form input, .note-form select, .scan-form input, .pay-form input,
.org-table input, .org-table select, .appr-add, .po-line input, .po-line select, .adv-item input, .adv-item select, .rcv-input {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); min-height: 38px; }
.field textarea { resize: vertical; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.inline-form .note { flex-basis: 100%; margin: 0; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.search { max-width: 340px; }
.tabs { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 8px; align-self: flex-start; }
.tab { border: 0; background: none; padding: 6px 14px; border-radius: 6px; cursor: pointer; color: var(--muted); font-weight: 500; }
.tab-on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* Bảng kanban */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.board-col { background: var(--surface-2); border-radius: var(--r); padding: 10px; display: flex; flex-direction: column; gap: 10px; min-height: 160px; }
.board-head { display: flex; justify-content: space-between; align-items: center; }
.count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; font-weight: 600; }
.board-cards { display: flex; flex-direction: column; gap: 8px; }
.board-empty { color: var(--muted); font-size: 12px; text-align: center; padding: 12px 0; }
.card-lead { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; }
.card-lead:hover { border-color: var(--accent); }
.card-need { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.card-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.card-meta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Chi tiết */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.detail-main, .detail-side { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.facts { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px 12px; margin: 0; }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 0; }
.facts-inline { grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr); }
.lock { margin: 14px 0; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); color: var(--muted); font-size: 13px; }
.lock-on { background: var(--oak-soft); color: var(--oak); }
.mini-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }

.quote { border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.quote + .quote { margin-top: 12px; }
.quote-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.quote-code { font-weight: 600; }
.quote-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.quote-items li { display: flex; justify-content: space-between; gap: 16px; font-size: 13.5px; }
.quote-items li > .mono { white-space: nowrap; color: var(--muted); }
.quote-sum { margin: 0; color: var(--muted); font-size: 12.5px; }
.quote-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.quote-foot { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; margin-top: 16px; align-items: start; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; margin: 0; padding: 14px; background: var(--surface-2); border-radius: 8px; font-variant-numeric: tabular-nums; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; text-align: right; font-family: var(--font-mono); font-size: 13px; }
.totals .totals-strong { color: var(--ink); font-weight: 700; font-size: 15px; padding-top: 6px; border-top: 1px solid var(--line); }

.note-form { display: grid; grid-template-columns: 130px minmax(0, 1fr) auto; gap: 8px; margin-bottom: 14px; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.tl { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; padding: 9px 0; border-top: 1px dashed var(--line); font-size: 13.5px; }
.tl:first-child { border-top: 0; }
.tl-when { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.tl-he_thong .tl-what { color: var(--muted); }

/* Công trình */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card-project { display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); cursor: pointer; }
.card-project:hover { border-color: var(--accent); }
.cp-top { display: flex; justify-content: space-between; align-items: center; }
.cp-code { color: var(--accent); font-weight: 600; }
.cp-name { font-size: 15px; }
.cp-addr { color: var(--muted); font-size: 12.5px; }
.cp-foot { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; font-variant-numeric: tabular-nums; margin-top: 4px; }
.cp-paid { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }

.steps { list-style: none; margin: 6px 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.step { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.step::before { content: ""; position: absolute; top: 5px; left: -50%; width: 100%; height: 2px; background: var(--line); }
.step:first-child::before { display: none; }
.step-done::before, .step-now::before { background: var(--accent); }
.step-dot { position: relative; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line); z-index: 1; }
.step-done .step-dot { background: var(--accent); border-color: var(--accent); }
.step-now .step-dot { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.step-label { font-size: 11px; color: var(--muted); line-height: 1.2; }
.step-now .step-label { color: var(--ink); font-weight: 600; }

.pay-form { display: flex; gap: 6px; justify-content: flex-end; }
.pay-form input { width: 120px; min-height: 30px; padding: 4px 8px; text-align: right; font-family: var(--font-mono); font-size: 12.5px; }

/* Sản xuất */
.prod-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.prod-line { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; margin-bottom: 6px; }
.track { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.track-seg { font-size: 10.5px; text-align: center; padding: 4px 2px; border-radius: 3px; background: var(--surface-2); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-done { background: var(--accent); color: var(--accent-ink); }
.track-now { background: var(--oak-soft); color: var(--oak); font-weight: 600; box-shadow: inset 0 0 0 1px var(--oak); }
.scan { border-color: var(--accent); }
.scan-form { display: flex; gap: 8px; margin-top: 12px; max-width: 520px; }
.scan-form input { font-size: 17px; letter-spacing: .02em; text-transform: uppercase; }
.scan-ok { margin: 10px 0 0; padding: 8px 12px; border-radius: var(--r-sm); background: var(--ok-soft); color: var(--ok); font-weight: 600; font-size: 13.5px; }
.stage-board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(150px, 1fr); gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.stage-col { display: flex; flex-direction: column; gap: 6px; background: var(--surface-2); padding: 8px; border-radius: 8px; min-height: 90px; }
.stage-col header { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; }
.stage-card { display: flex; flex-direction: column; gap: 4px; padding: 8px; border-radius: 6px; background: var(--surface); border: 1px solid var(--line); font-size: 12.5px; }
.orders { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 22px; }
.order { display: flex; flex-direction: column; gap: 10px; }
.order + .order { padding-top: 18px; border-top: 1px solid var(--line); }
.order-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-weight: 600; }

/* Lắp đặt */
.installs { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.install { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); }
.install-done { opacity: .85; }
.install-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.install-actions { display: flex; flex-direction: column; gap: 12px; }
.accept-form { display: flex; flex-direction: column; gap: 10px; padding-top: 12px; border-top: 1px dashed var(--line); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.photos img { width: 100%; aspect-ratio: 1; max-width: 100%; object-fit: cover; border-radius: 6px; }

/* Hộp thoại */
.modal-back { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; background: rgba(12, 16, 14, .45); }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--surface); border-radius: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal-wide { width: min(1080px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 8px; }
.modal-head h2 { font: 600 19px/1.2 var(--font-display); }
.modal-body { padding: 8px 18px 16px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.foot-total { margin-right: auto; display: flex; flex-direction: column; font-size: 12px; color: var(--muted); }
.foot-total strong { font-size: 18px; color: var(--ink); }

.toasts { position: fixed; z-index: 40; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 11px 14px; border-radius: 8px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow); font-weight: 500; font-size: 13.5px; }
.toast-bad { background: var(--bad); color: #fff; }

/* Đăng nhập / chọn vai trò */
.login { min-height: 100%; display: grid; place-items: center; padding-block: 32px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.login-card { width: min(920px, 100%); display: flex; flex-direction: column; gap: 18px; }
.login-narrow { width: min(380px, 100%); padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.login-lede { margin: 0; max-width: 60ch; color: var(--muted); font-size: 15px; }
.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.role-grid-tight { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.role-card { display: flex; flex-direction: column; gap: 3px; text-align: left; padding: 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.role-card:hover, .role-on { border-color: var(--accent); background: var(--accent-soft); }
.role-name { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.role-hint { font-size: 12.5px; color: var(--muted); }

/* ---------- Màn hình nhỏ ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .detail { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .brand-top { display: flex; font-size: 16px; }
  .topbar { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .content { padding-block: 18px calc(88px + env(safe-area-inset-bottom, 0px)); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .tabbar { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    padding-block: 6px calc(6px + env(safe-area-inset-bottom, 0px)); padding-left: max(4px, env(safe-area-inset-left, 0px)); padding-right: max(4px, env(safe-area-inset-right, 0px));
    background: var(--surface); border-top: 1px solid var(--line); }
  .tab-item { display: flex; flex-direction: column; align-items: center; gap: 2px; border: 0; background: none; color: var(--muted); font-size: 10.5px; padding: 4px 2px; cursor: pointer; min-width: 0; }
  .tab-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .tab-item-on { color: var(--accent); font-weight: 600; }
  .demo-tag { display: none; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .page-head h1 { font-size: 23px; }
  .toasts { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 560px) {
  .kpis, .kpis-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-value { font-size: 21px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .quote-foot { grid-template-columns: minmax(0, 1fr); }
  .note-form { grid-template-columns: minmax(0, 1fr); }
  .status-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .steps .step-label { font-size: 9.5px; }
  .installs, .cards { grid-template-columns: minmax(0, 1fr); }
  .facts-inline { grid-template-columns: 90px minmax(0, 1fr); }
  .board { grid-auto-columns: minmax(78%, 1fr); }
  .modal-back { align-items: end; padding: 0; }
  .modal { width: 100%; max-height: 92vh; border-radius: 14px 14px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .search { max-width: none; }
  .row-meter { min-width: 110px; }
  .bar-row { grid-template-columns: 80px minmax(0, 1fr) 56px; }
}

/* =========================================================
   Bổ sung: chi phí, mua hàng, nhập Excel, hồ sơ hợp đồng,
   sản xuất xong/chưa xong, ảnh lắp đặt, biên bản nghiệm thu
   ========================================================= */
.txt-ok { color: var(--ok); }
.txt-warn { color: var(--warn); }
.txt-strong { font-weight: 600; }
.clip-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cell-sub-inline { color: var(--muted); font-size: 12px; margin-left: 6px; }
.w-full { width: 100%; }
.btn-disabled { opacity: .55; pointer-events: none; }

/* Khách kỹ tính */
.demanding { display: inline-flex; }
.card-demanding { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)) !important; box-shadow: inset 3px 0 0 var(--bad); }
.alert-demanding { margin: 0; padding: 10px 14px; border-radius: var(--r-sm); background: var(--bad-soft); color: var(--bad); font-size: 13.5px; }
.alert-demanding strong { margin-right: 4px; }
.alert-sm { padding: 7px 10px; font-size: 12.5px; }
.note-block { margin: 0; white-space: pre-wrap; font-size: 13.5px; line-height: 1.55; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }

/* Nhãn loại hàng / chi phí */
.kind { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 11px; font-weight: 600; letter-spacing: .02em; vertical-align: 1px; background: var(--surface-2); color: var(--muted); }
.kind-san_xuat, .kind-c-san_xuat { background: var(--accent-soft); color: var(--accent); }
.kind-mua_ngoai, .kind-c-mua_ngoai { background: var(--oak-soft); color: var(--oak); }
.kind-dich_vu { background: var(--surface-2); color: var(--muted); }
.kind-c-phat_sinh_noi_bo { background: var(--bad-soft); color: var(--bad); }
.kind-c-phat_sinh_khach { background: var(--warn-soft); color: var(--warn); }

/* Báo giá: hạng mục theo không gian */
.qitems { display: flex; flex-direction: column; gap: 14px; }
.qarea-head { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.qarea ul { list-style: none; margin: 0; padding: 0; }
.qitem { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.qitem:last-child { border-bottom: 0; }
.qitem-sub { padding-left: 28px; grid-template-columns: 36px minmax(0, 1fr) auto; }
.qitem-img { width: 100%; aspect-ratio: 4 / 3; max-width: 100%; object-fit: cover; border-radius: 6px; background: var(--surface-2); }
.qitem-noimg { display: block; }
.qitem-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 13.5px; }
.qitem-name { font-weight: 600; }
.qitem-money { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; font-size: 12.5px; color: var(--muted); }
.qitem-money strong { color: var(--ink); font-size: 13.5px; }
.internal { display: block; margin-top: 3px; padding: 3px 8px; border-left: 2px solid var(--warn); background: var(--warn-soft); color: var(--warn); font-size: 12px; border-radius: 0 4px 4px 0; }
.quote-src { margin: 0; font-size: 12.5px; color: var(--muted); }
.terms-list { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.cell-stack { display: flex; flex-direction: column; gap: 4px; min-width: 200px; }
.w-area { width: 130px !important; }
.w-unit { width: 64px !important; }

/* Nhập Excel */
.drop { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px 20px; border: 2px dashed var(--line); border-radius: var(--r); text-align: center; color: var(--muted); cursor: pointer; }
.drop strong { color: var(--ink); font-size: 15px; }
.drop span { max-width: 60ch; font-size: 13px; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop:hover, .drop-on { border-color: var(--accent); background: var(--accent-soft); }
.import { display: flex; flex-direction: column; gap: 12px; }
.import-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.mapping summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--accent); }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin-top: 10px; }
.map-cell { display: flex; flex-direction: column; gap: 3px; padding: 8px; border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 12px; min-width: 0; }
.map-head { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-cell select { padding: 4px 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.warn-list { margin: 0; padding: 10px 14px 10px 30px; border-radius: var(--r-sm); background: var(--warn-soft); color: var(--warn); font-size: 13px; }
.table-import { min-width: 760px; }
.table-import td { vertical-align: top; font-size: 13px; }
.table-import td:nth-child(2) { min-width: 240px; max-width: 360px; }
.table-import select { padding: 4px 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.area-row th { background: var(--surface-2); color: var(--ink); font-size: 11.5px; letter-spacing: .06em; }
.row-sub-item td:nth-child(2) { padding-left: 24px; }
.mini-img { width: 72px; height: 54px; object-fit: cover; border-radius: 4px; display: block; }
.terms { margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.terms ul { margin: 4px 0 0; padding-left: 18px; }

/* Hồ sơ hợp đồng */
.dossier { display: flex; flex-direction: column; gap: 16px; margin-top: 12px; }
.dossier-sec { display: flex; flex-direction: column; gap: 8px; }
.dossier-sec h3 { margin: 0; font-size: 14px; }
.req { font-size: 11px; font-weight: 600; color: var(--bad); margin-left: 6px; text-transform: uppercase; letter-spacing: .04em; }
.link-add { display: flex; gap: 8px; flex-wrap: wrap; }
.link-add input { flex: 1 1 240px; min-width: 0; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.links li { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; padding: 4px 8px; background: var(--surface-2); border-radius: 4px; min-width: 0; }
.links a, .link-line { color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; max-width: 100%; }
.checklist { padding: 10px 14px; border-radius: var(--r-sm); background: var(--warn-soft); color: var(--warn); font-size: 13px; }
.checklist ul { margin: 4px 0 0; padding-left: 18px; }

/* Ảnh */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.thumbs-sm { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
.thumb { position: relative; margin: 0; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.thumb-img { padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 6px; overflow: hidden; }
.thumb-img img { width: 100%; aspect-ratio: 1; max-width: 100%; object-fit: cover; display: block; background: var(--surface-2); }
.thumb figcaption { font-size: 11px; color: var(--muted); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb-x { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .55); color: #fff; cursor: pointer; line-height: 1; font-size: 15px; }
.lightbox { display: block; max-width: 100%; max-height: 72vh; margin: 0 auto; border-radius: 8px; }

/* Lựa chọn dạng nút */
.seg { display: flex; flex-wrap: wrap; gap: 6px; border: 0; padding: 0; margin: 0; }
.seg legend { margin-bottom: 6px; padding: 0; }
.seg-opt { display: inline-flex; align-items: center; padding: 7px 12px; border: 1px solid var(--line); border-radius: 99px; cursor: pointer; font-size: 13px; font-weight: 500; }
.seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg-on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.seg-opt:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Chi phí & lãi gộp */
.profit { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.profit > div { display: flex; flex-direction: column; gap: 2px; padding: 10px; background: var(--surface-2); border-radius: var(--r-sm); min-width: 0; }
.profit strong { font-size: 13.5px; overflow-wrap: anywhere; }
.bars-tight { gap: 7px; }
.bars-tight .bar-row { grid-template-columns: 96px minmax(0, 1fr) 58px; }
.bar-accent { background: var(--accent); } .bar-bad { background: var(--bad); } .bar-warn { background: var(--warn); }
.cost-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; }
.cost-list li { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13px; }
.cost-list li > div:first-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; align-items: flex-start; }
.cost-right { display: flex; align-items: center; gap: 2px; white-space: nowrap; }
.row-change td { background: color-mix(in srgb, var(--warn-soft) 55%, transparent); }
.detail-side .pay-form input { width: 96px; }
.detail-side .table-tight td:first-child { min-width: 72px; }

/* Danh sách tích chọn: sản xuất, mua hàng */
.batch { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; margin-bottom: 8px; background: var(--surface-2); border-radius: var(--r-sm); }
.batch-input { flex: 1 1 180px; min-width: 0; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); min-height: 30px; }
.check-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.check-list > li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 4px 10px; padding: 10px 4px; border-top: 1px solid var(--line); }
.check-list > li:first-child { border-top: 0; }
.check-list > li > input[type=checkbox] { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); }
.check-list .is-done .cl-main > span:first-child { color: var(--muted); }
.check-list .is-sel { background: var(--accent-soft); border-radius: 6px; }
.cl-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 13.5px; cursor: pointer; }
.cl-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.dot { width: 12px; height: 12px; margin-top: 4px; border-radius: 50%; border: 2px solid var(--line); }
.dot-on { background: var(--ok); border-color: var(--ok); }
.note-btn { border: 0; background: none; padding: 0; color: var(--accent); font-size: 12px; cursor: pointer; }
.notes { grid-column: 1 / -1; padding: 10px 12px; margin-top: 4px; background: var(--surface-2); border-radius: var(--r-sm); }
.notes .note-form { margin: 10px 0 0; }
.prod-area + .prod-area { margin-top: 10px; }
.prod-area-title { margin: 6px 0 2px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.order.panel { display: flex; flex-direction: column; gap: 10px; }
.order.panel + .order.panel { padding-top: 18px; border-top: 1px solid var(--line); }

/* Lắp đặt: yêu cầu ảnh */
.rule { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: var(--r-sm); }
.rule-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; font-size: 13.5px; }
.rule-min { display: inline-flex; align-items: center; gap: 6px; }
.rule-min input { width: 58px; padding: 5px 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); text-align: center; }
.photo-check { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--warn-soft); }
.photo-ok { background: var(--ok-soft); }
.pc-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13.5px; }
.pc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.pc-list li { padding: 3px 9px; border-radius: 99px; font-size: 12px; background: var(--surface); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); }
.pc-list li::before { content: "○ "; }
.pc-list .pc-done { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.pc-list .pc-done::before { content: "✓ "; }
.photo-add { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.photo-add .field { flex: 1 1 220px; }

/* Biên bản nghiệm thu */
.docs { display: flex; flex-direction: column; gap: 12px; }
.doc { display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r); }
.doc .note { margin: 0; }
.doc-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.doc-signed { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); background: color-mix(in srgb, var(--ok-soft) 35%, var(--surface)); }
.doc-off { opacity: .7; border-style: dashed; }
.doc-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.handover { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.handover .table-wrap { width: 100%; }
.handover .table { min-width: 520px; }
.handover input:not([type=checkbox]) { padding: 5px 8px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); min-width: 160px; }
.handover input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--ok); }
.row-issue td { background: color-mix(in srgb, var(--bad-soft) 60%, transparent); }
.paper { background: #fff; color: #1a1a1a; padding: 28px 32px; border: 1px solid #ddd; border-radius: 4px; font: 14px/1.6 var(--font-display); color-scheme: light; }
.paper-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: 12px; text-align: center; }
.paper-head strong { font-family: var(--font-ui); font-size: 12px; }
.paper-title { margin: 20px 0 6px; text-align: center; font: 700 18px/1.3 var(--font-display); letter-spacing: .02em; }
.paper-meta { text-align: center; margin: 0 0 14px; font-size: 13px; }
.paper-parties { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 4px 12px; margin: 0 0 14px; }
.paper-parties dt { font-weight: 700; }
.paper-parties dd { margin: 0; }
.paper-table { width: 100%; border-collapse: collapse; font: 13px/1.45 var(--font-ui); margin: 8px 0 12px; }
.paper-table th, .paper-table td { border: 1px solid #999; padding: 5px 8px; text-align: left; vertical-align: top; }
.paper-table th { background: #f1f1f1; }
.paper-table .num { text-align: right; }
.paper-table tfoot td, .paper-sum td { font-weight: 700; }
.paper-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 28px; text-align: center; }
.paper-sign div { display: flex; flex-direction: column; gap: 46px; }
.paper-sign span { font-style: italic; font-size: 13px; }

/* Bảng gọn trong tổng quan */
.table-narrow { min-width: 0; }
.table-click-row { cursor: pointer; }
.table-click-row:hover td { background: var(--surface-2); }
.cp-tags { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; }
.cp-margin { font-size: 12px; color: var(--muted); }

@media (max-width: 560px) {
  .profit { grid-template-columns: minmax(0, 1fr); }
  .qitem { grid-template-columns: 52px minmax(0, 1fr); }
  .qitem-money { grid-column: 2; align-items: flex-start; text-align: left; }
  .paper { padding: 18px 14px; }
  .paper-parties { grid-template-columns: minmax(0, 1fr); }
  .rule-row { flex-direction: column; align-items: flex-start; }
  .check-list > li { grid-template-columns: auto minmax(0, 1fr); }
  .check-list .cl-right, .check-list > li > .badge { grid-column: 2; justify-self: start; flex-direction: row; }
}
@media print {
  body * { visibility: hidden; }
  .paper, .paper * { visibility: visible; }
  .paper { position: absolute; inset: 0; border: 0; }
}
.detail-side .profit { grid-template-columns: minmax(0, 1fr); gap: 4px; }
.detail-side .profit > div { flex-direction: row; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 10px; padding: 8px 10px; }
.detail-side .profit .cell-sub { flex-basis: 100%; text-align: right; }
.detail-side .pay-form input { width: 84px; }

/* Phân công & theo dõi, phân quyền */
.watchers { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 99px; background: var(--oak-soft); color: var(--ink); font-size: 12.5px; }
.chip-role { color: var(--oak); font-size: 11px; font-weight: 600; }
.chip-x { width: 20px; height: 20px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; }
.chip-x:hover { background: var(--surface); color: var(--bad); }
.watch-add { display: flex; gap: 6px; }
.watch-add select { flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.watchers .note { margin: 0; }
.assign { grid-template-columns: 84px minmax(0, 1fr); align-items: center; }
.assign select { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.cp-tags-left { justify-content: flex-start; }
.alert-info { margin: 0; padding: 10px 14px; border-radius: var(--r-sm); background: var(--warn-soft); color: var(--warn); font-size: 13.5px; }
.alert-info .linkish { color: var(--accent); margin-left: 6px; }
.perm-table td { vertical-align: middle; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.switch input { appearance: none; width: 36px; height: 20px; border-radius: 99px; background: var(--line); position: relative; cursor: pointer; transition: background .15s; flex: none; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); transition: transform .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }
.plain-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
/* Bảng thanh toán ở cột hẹp: ô thu tiền xuống dòng riêng */
.detail-side .table-tight thead th:last-child { display: none; }
.detail-side .table-tight tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: start; border-bottom: 1px solid var(--line); }
.detail-side .table-tight thead tr { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; }
.detail-side .table-tight tbody td { border-bottom: 0; }
.detail-side .table-tight tbody td:last-child { grid-column: 1 / -1; padding-top: 0; }
.detail-side .table-tight tbody td:last-child:empty { display: none; }
.detail-side .pay-form { justify-content: stretch; }
.detail-side .pay-form input { flex: 1; width: auto; }

/* Quản trị */
.admin-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.admin-bar .note { margin: 0; flex: 1 1 320px; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.logo-box { display: grid; place-items: center; height: 140px; margin-bottom: 12px; border: 1px dashed var(--line); border-radius: var(--r); background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0 / 16px 16px; }
.logo-box img { max-width: 80%; max-height: 110px; object-fit: contain; }
.brand-mark-lg { width: 56px; height: 56px; }
.brand-logo { height: 26px; width: auto; max-width: 120px; object-fit: contain; }
.brand-lg .brand-logo { height: 36px; }
.brand-preview { margin-top: 14px; padding: 12px; border-radius: var(--r-sm); background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }
.paper-logo { height: 34px; width: auto; object-fit: contain; }
.paper-head { align-items: center; }
.menu-matrix th.center, .menu-matrix td.center { text-align: center; }
.menu-matrix input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.menu-matrix .dash { color: var(--line); }
.menu-matrix th { white-space: normal; min-width: 64px; }
.row-off td { color: var(--muted); }
.row-off td strong { font-weight: 500; }
@media (max-width: 860px) { .admin-grid { grid-template-columns: minmax(0, 1fr); } }

/* Phân loại khách & tag */
.tone-accent { --tone: var(--accent); --tone-soft: var(--accent-soft); }
.tone-oak { --tone: var(--oak); --tone-soft: var(--oak-soft); }
.tone-ok { --tone: var(--ok); --tone-soft: var(--ok-soft); }
.tone-warn { --tone: var(--warn); --tone-soft: var(--warn-soft); }
.tone-bad { --tone: var(--bad); --tone-soft: var(--bad-soft); }
.tone-neutral { --tone: var(--muted); --tone-soft: var(--surface-2); }
.seg-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--tone); white-space: nowrap; }
.seg-badge::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--tone); }
.tag-list { display: inline-flex; flex-wrap: wrap; gap: 4px; vertical-align: middle; }
.tag { display: inline-flex; align-items: center; gap: 3px; padding: 1px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 500; background: var(--tone-soft); color: var(--tone); border: 1px solid transparent; white-space: nowrap; }
button.tag { cursor: pointer; font: inherit; font-size: 11.5px; }
.tag-add { background: transparent; border-color: color-mix(in srgb, var(--tone) 35%, transparent); }
.tag-add:hover { background: var(--tone-soft); }
.tag-on { border-color: var(--tone); box-shadow: inset 0 0 0 1px var(--tone); font-weight: 700; }
.tag-x { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 0 0 2px; font-size: 13px; line-height: 1; opacity: .7; }
.tag-x:hover { opacity: 1; }
.tag-count { font-variant-numeric: tabular-nums; opacity: .75; }
.tag-picker { display: flex; flex-direction: column; gap: 8px; }
.tag-quick { display: flex; flex-wrap: wrap; gap: 5px; }
.tag-new { display: flex; gap: 6px; }
.tag-new input { flex: 1; min-width: 0; padding: 6px 9px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.tag-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tag-filter .field-label { margin-right: 4px; }
.tag-stats { margin-top: 12px; }
.filter-select { padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); min-height: 38px; max-width: 240px; }
.card-cls { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.classify { display: flex; flex-direction: column; gap: 10px; }
.classify select { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.cls-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cls-list li { display: grid; grid-template-columns: minmax(0, 1fr) 110px 70px 34px; gap: 6px; align-items: center; }
.cls-list input { padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); min-width: 0; }
.tone-select { padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--tone-soft); color: var(--tone); font-weight: 600; }
.cls-count { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.admin-grid-even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 860px) { .admin-grid-even { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 560px) { .cls-list li { grid-template-columns: minmax(0, 1fr) 90px 34px; } .cls-count { display: none; } .filter-select { max-width: none; flex: 1; } }

/* =========================================================
   Giao diện phương án A — menu trái dải hồng tím, thẻ chỉ số màu chuyển,
   khối trắng bo góc lớn, bảng tiêu đề nền tối
   ========================================================= */
.shell { grid-template-columns: 248px minmax(0, 1fr); }
.side { padding: 0; gap: 0; border-right: 1px solid var(--line); overflow-y: auto; }
.side-brand { display: flex; align-items: center; gap: 12px; padding: 26px 22px; background: var(--grad); color: #fff; }
.side-brand .brand-tile { background: #fff; color: var(--g-to); }
.side-brand-text { display: flex; flex-direction: column; min-width: 0; }
.side-brand-text strong { font-size: 17px; font-weight: 700; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-brand-text span { font-size: 12px; opacity: .95; }
.side-nav { padding: 18px 14px; gap: 4px; }
.nav-item { min-height: 44px; padding: 0 14px; border-radius: 10px; color: var(--ink); font-weight: 500; font-size: 14px; }
.nav-item svg { color: var(--muted); flex: none; }
.nav-item:hover { background: var(--surface-2); }
.nav-on, .nav-on:hover { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-on svg { color: var(--accent); }
.side-foot { margin: auto 14px 14px; padding: 12px; border: 0; border-radius: 14px; background: var(--surface-2); display: flex; align-items: center; gap: 10px; }
.brand-tile { flex: none; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--grad); color: #fff; font-weight: 700; font-size: 16px; letter-spacing: -.02em; overflow: hidden; }
.brand-tile img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.brand-tile-sm { width: 34px; height: 34px; border-radius: 10px; font-size: 13px; }
.avatar { flex: none; width: 38px; height: 38px; border-radius: 99px; display: grid; place-items: center; background: var(--grad); color: #fff; font-weight: 600; font-size: 13px; }
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-soft { background: var(--accent-soft); color: var(--accent); }

.topbar { background: color-mix(in srgb, var(--bg) 90%, transparent); border-bottom: 0; min-height: 64px; }
.brand-top { align-items: center; gap: 10px; font: 700 16px/1 var(--font-ui); }
.content { max-width: 1320px; gap: 22px; padding-top: 8px; }

.page-head h1 { font: 700 28px/1.2 var(--font-ui); letter-spacing: -.015em; }
.page-sub { font-size: 14px; }

.btn { min-height: 42px; border-radius: 12px; padding: 0 18px; font-weight: 600; }
.btn-sm { min-height: 34px; border-radius: 10px; padding: 0 12px; }
.btn-primary { background: var(--grad); border-color: transparent; color: #fff; }
.btn-primary:hover { background: var(--grad); filter: brightness(1.06); border-color: transparent; }
.btn-ghost { border-color: var(--line); }

.panel { border: 0; border-radius: var(--r); padding: 22px 24px; box-shadow: var(--shadow); }
.panel-head { margin-bottom: 14px; }
.panel h2, .side-title { font-size: 16px; font-weight: 600; }
.panel-attn { border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); background: color-mix(in srgb, var(--warn-soft) 55%, var(--surface)); }

/* Thẻ chỉ số màu chuyển */
.kpis { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; }
.kpi { border: 0; border-radius: var(--r); padding: 20px 22px; gap: 8px; min-height: 140px; color: #fff; background: linear-gradient(135deg, #c2185b, #7b3fe4); box-shadow: var(--shadow); }
.kpis .kpi:nth-child(4n+2) { background: linear-gradient(135deg, #6a3de8, #2f4fc9); }
.kpis .kpi:nth-child(4n+3) { background: linear-gradient(135deg, #b8360b, #a61e4d); }
.kpis .kpi:nth-child(4n+4) { background: linear-gradient(135deg, #0b6e80, #1a5fa8); }
.kpi-label { color: #fff; font-size: 14px; font-weight: 500; letter-spacing: 0; text-transform: none; }
.kpi-value { font: 700 30px/1.1 var(--font-ui); }
.kpi-sub { color: #fff; font-size: 13px; margin-top: auto; }
.kpi-bad { border: 0; }
.kpi-bad .kpi-sub { color: #fff; }
.kpi-flag { align-self: flex-start; background: rgba(255, 255, 255, .2); padding: 2px 10px; border-radius: 99px; font-weight: 600; }
.kpi-plain { color: var(--ink) !important; background: var(--surface) !important; }
.kpi-plain .kpi-label, .kpi-plain .kpi-sub { color: var(--muted); }

/* Bảng: tiêu đề nền tối */
.table { border-collapse: separate; border-spacing: 0; }
.table thead th { background: var(--head); color: var(--head-ink); font-size: 12px; letter-spacing: .02em; text-transform: none; font-weight: 600; padding: 11px 12px; border-bottom: 0; }
.table thead th:first-child { border-top-left-radius: 10px; }
.table thead th:last-child { border-top-right-radius: 10px; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); }
.table-tight thead th { padding: 9px 8px; }
.table-tight td { padding: 8px; }
.table-click tbody tr:hover td, .table-click-row:hover td { background: var(--accent-soft); }

.tabs { background: var(--surface); box-shadow: var(--shadow); border-radius: 12px; padding: 5px; gap: 4px; }
.tab { padding: 8px 16px; border-radius: 9px; color: var(--muted); }
.tab-on { background: var(--head); color: var(--head-ink); box-shadow: none; font-weight: 600; }

.badge { padding: 3px 10px; }
.bar-track { height: 10px; }
.bar-fill { background: var(--grad); }
.bar-oak { background: linear-gradient(90deg, #f08c00, #d6336c); }
.progress-accent { background: var(--grad); }
.card-lead, .card-project, .install, .role-card, .quote, .doc { border-radius: 14px; }
.card-lead:hover, .card-project:hover, .role-card:hover { border-color: var(--g-to); }
.board-col { border-radius: 16px; }
.field input, .field select, .field textarea, .search, .filter-select { border-radius: 10px; min-height: 42px; }
.modal { border-radius: 18px; }
.modal-head h2 { font: 700 19px/1.25 var(--font-ui); }
.login-narrow { border: 0; box-shadow: var(--shadow); border-radius: 20px; }
.role-name { color: var(--g-to); }
.brand-lg { font: 700 24px/1 var(--font-ui); gap: 12px; }

/* Tổng quan: biểu đồ */
.dash-row { display: flex; flex-wrap: wrap; gap: 20px; }
.dash-row > * { flex: 1 1 300px; }
.dash-row > .dash-wide { flex: 2 1 480px; }
.area { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; }
.area-y { display: flex; flex-direction: column; justify-content: space-between; height: 196px; font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.area svg { width: 100%; height: 196px; display: block; }
.area-x { grid-column: 2; display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.area-x span { flex: 1; text-align: center; }
.area-x span:first-child { text-align: left; } .area-x span:last-child { text-align: right; }
.donut { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; }
.donut-ring { position: relative; width: 150px; height: 150px; flex: none; }
.donut-ring svg { width: 150px; height: 150px; display: block; transform: rotate(-90deg); }
.donut-mid { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-mid strong { font-size: 26px; font-weight: 700; line-height: 1.1; }
.donut-mid span { font-size: 12px; color: var(--muted); }
.legend { list-style: none; margin: 0; padding: 0; flex: 1 1 160px; display: flex; flex-direction: column; gap: 9px; font-size: 13px; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend strong { margin-left: auto; font-variant-numeric: tabular-nums; }
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; font-size: 13px; }
.feed li { display: flex; gap: 12px; }
.feed-dot { flex: none; width: 12px; height: 12px; margin-top: 4px; border-radius: 99px; border: 3px solid var(--g-to); }
.feed-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.feed-body strong { font-weight: 600; }
.feed-body span { color: var(--muted); }
.pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.meter { display: flex; align-items: center; gap: 8px; min-width: 120px; font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* Chi tiết khách: khối hồ sơ */
.profile { display: flex; flex-direction: column; gap: 20px; border-top: 6px solid var(--g-to); }
.profile-top { display: flex; flex-wrap: wrap; align-items: center; gap: 18px 20px; }
.profile-avatar { flex: none; width: 72px; height: 72px; border-radius: 20px; display: grid; place-items: center; background: var(--grad); color: #fff; font-size: 24px; font-weight: 700; }
.profile-main { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.profile-name { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.profile-name h1 { font: 700 26px/1.2 var(--font-ui); letter-spacing: -.01em; }
.profile-contact { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 14px; color: var(--ink); }
.profile-contact > span { display: inline-flex; align-items: center; gap: 6px; }
.profile-contact svg { color: var(--muted); flex: none; }
.profile-contact .muted { color: var(--muted); }
.profile-actions { display: flex; flex-wrap: wrap; gap: 10px; align-self: flex-start; }
.profile-facts { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); border-top: 1px solid var(--line); padding-top: 18px; row-gap: 14px; }
.profile-facts > div { display: flex; flex-direction: column; gap: 4px; padding: 0 16px; border-left: 1px solid var(--line); min-width: 0; }
.profile-facts > div:first-child { border-left: 0; padding-left: 0; }
.profile-facts dt { font-size: 12px; color: var(--muted); }
.profile-facts dd { margin: 0; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.side-block { display: flex; flex-direction: column; gap: 8px; }
.side-block + .side-block { margin-top: 16px; }
.side-label { font-size: 12px; color: var(--muted); }
.alert-demanding { border-radius: 14px; border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); background: var(--warn-soft); color: var(--warn); padding: 14px 18px; }
.detail { grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; }

@media (max-width: 1100px) { .detail { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
  .tabbar { background: var(--surface); }
  .tab-item { min-height: 48px; justify-content: center; font-size: 11px; }
  .tab-item-on { color: var(--g-to); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kpi { min-height: 116px; padding: 16px; }
  .kpi-value { font-size: 23px; }
  .panel { padding: 18px; }
  .profile-facts > div { border-left: 0; padding-left: 0; }
  .profile-actions { width: 100%; }
}
@media (max-width: 560px) {
  .kpi-label { font-size: 12.5px; }
  .kpi-value { font-size: 20px; }
  .profile-avatar { width: 56px; height: 56px; font-size: 19px; border-radius: 16px; }
  .profile-name h1 { font-size: 21px; }
  .profile-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-actions .btn { flex: 1; }
  .donut-ring, .donut-ring svg { width: 128px; height: 128px; }
}
.legend-rev { min-width: 64px; text-align: right; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
@media (min-width: 1101px) {
  .detail-left { grid-template-columns: 340px minmax(0, 1fr); }
  .detail-left .detail-side { order: -1; }
}
.side-block .classify, .side-block .watchers { margin-top: 0; }
.side-block .watchers { padding-top: 8px; }
a.btn { text-decoration: none; color: inherit; }
.legend li { align-items: flex-start; }
.legend i { margin-top: 5px; }
.legend-name { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.legend-name small { color: var(--muted); font-size: 11.5px; }
.table td.mono { white-space: nowrap; }
.area-x em { font-style: normal; }
@media (max-width: 560px) { .area-x em { display: none; } .area svg, .area-y { height: 150px; } }
/* nhãn kiểu KPI dùng ngoài thẻ KPI (khối lãi gộp…) giữ màu chữ thường */
:not(.kpi) > .kpi-label { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }

/* Mất sóng */
.offline-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 14px; border-radius: 14px; background: var(--ok-soft); color: var(--ok); font-size: 13.5px; }
.offline-bar-off { background: var(--warn-soft); color: var(--warn); }
.offline-dot { width: 9px; height: 9px; border-radius: 99px; background: currentColor; flex: none; }
.offline-text { flex: 1 1 220px; }
.offline-bar .btn { color: var(--ink); }
.pending-photos { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border: 1px dashed color-mix(in srgb, var(--warn) 45%, transparent); border-radius: 12px; background: color-mix(in srgb, var(--warn-soft) 50%, transparent); }
.pending-photos img { opacity: .8; }

/* Chuông thông báo */
.bell { position: relative; }
.bell-btn { position: relative; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.bell-count { position: absolute; top: -5px; right: -5px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 99px; background: var(--g-from); color: #fff; font-size: 11px; font-weight: 700; line-height: 19px; text-align: center; border: 2px solid var(--surface); box-sizing: content-box; }
.bell-panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: 25; width: min(400px, calc(100vw - 24px)); max-height: min(560px, calc(100vh - 90px)); display: flex; flex-direction: column; background: var(--surface); border-radius: 18px; box-shadow: 0 18px 50px rgba(20, 21, 42, .22); overflow: hidden; }
.bell-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 10px; }
.bell-head .linkish { color: var(--accent); font-size: 13px; }
.bell-push { margin: 0 12px 8px; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); color: var(--ink); font-size: 12.5px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.bell-push span { flex: 1 1 200px; }
.bell-list { list-style: none; margin: 0; padding: 0 6px 8px; overflow-y: auto; }
.bell-item { width: 100%; display: flex; gap: 12px; align-items: flex-start; padding: 10px; border: 0; border-radius: 12px; background: none; text-align: left; cursor: pointer; color: var(--ink); }
.bell-item:hover { background: var(--surface-2); }
.bell-unread { background: color-mix(in srgb, var(--accent-soft) 60%, transparent); }
.bell-unread .bell-text strong::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 6px; border-radius: 99px; background: var(--g-from); vertical-align: 2px; }
.bell-ico { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--accent-soft); color: var(--accent); }
.bell-ok { background: var(--ok-soft); color: var(--ok); } .bell-warn { background: var(--warn-soft); color: var(--warn); } .bell-bad { background: var(--bad-soft); color: var(--bad); }
.bell-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 13px; line-height: 1.4; }
.bell-text strong { font-weight: 600; }
.bell-text span { color: var(--muted); overflow-wrap: anywhere; }
.bell-text small { color: var(--muted); font-size: 11.5px; }
@media (max-width: 560px) {
  .bell-panel { position: fixed; left: 12px; right: 12px; top: calc(64px + env(safe-area-inset-top, 0px)); width: auto; max-height: calc(100vh - 170px); }
}

/* ---------- Đợt 1: khách hàng B2B, cổng khách, phản hồi, phân quyền ---------- */
button.tag:not([class*="tone-"]), .cf-multi .tag:not(.tag-on) { --tone: var(--muted); --tone-soft: var(--surface-2); cursor: pointer; }
.cf-multi, .cf-groups { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.subform { padding: 14px; border-radius: var(--r-sm); background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; }
.subform .form-grid { gap: 10px 12px; }
.card-cust { font-size: 12.5px; font-weight: 600; color: var(--g-to); }
.text-warn { color: var(--warn); }
.group-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: thin; }
.group-chip { --tone: var(--g-to); --tone-soft: var(--accent-soft); flex: none; display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600; font-size: 13px; cursor: pointer; }
.group-chip span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.group-chip:hover { border-color: var(--tone); }
.group-chip.on { background: var(--tone-soft); border-color: var(--tone); color: var(--tone); }
.group-chip.on span { color: inherit; }
.cust-cell { display: flex; align-items: center; gap: 10px; }
.cust-table tfoot td { font-weight: 700; border-top: 2px solid var(--line); padding-top: 10px; }
.profile-avatar.tone-accent, .profile-avatar.tone-oak, .profile-avatar.tone-ok, .profile-avatar.tone-warn, .profile-avatar.tone-bad { background: var(--grad); }
.profile-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.cust-projects { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cp-row { width: 100%; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; text-align: left; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface); cursor: pointer; }
.cp-row:hover { border-color: var(--g-to); }
.cp-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 260px; }
.cp-side { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 13px; }
.cp-side .cell-sub { display: inline; }
.cp-lost { opacity: .65; }
.side-cust { display: block; font-size: 15px; }
.side-block .classify { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cf-facts { grid-template-columns: minmax(90px, 40%) minmax(0, 1fr); }
.acc-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.acc-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r-sm); background: var(--surface-2); }

/* Phản hồi */
.fb { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; background: var(--surface); }
.fb-open { border-left: 4px solid var(--g-from); }
.fb-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 12px; }
.fb-meta { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.fb-msgs { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.fb-msg { max-width: 86%; padding: 8px 12px; border-radius: 14px; background: var(--surface-2); }
.fb-msg p { margin: 2px 0 0; white-space: pre-wrap; }
.fb-msg-staff { align-self: flex-end; background: var(--accent-soft); }
.fb-msg-cust { align-self: flex-start; background: var(--oak-soft); }
.fb-who { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.fb-imgs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.fb-imgs img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; display: block; }
.fb-reply { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.fb-reply textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); resize: vertical; }
.fb-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; align-items: center; }

/* Cổng khách hàng */
.contact-card { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.contact-card > div { flex: 1 1 180px; }
.portal-projects { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.pp-card { width: 100%; text-align: left; display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); cursor: pointer; }
.pp-card:hover { border-color: var(--g-to); }
.pp-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.pp-money { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--muted); }
.portal-quote { padding: 6px 0 0; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.photo-grid .photo { display: flex; flex-direction: column; gap: 4px; color: inherit; text-decoration: none; }
.photo-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; display: block; background: var(--surface-2); }
.photo-cap { font-size: 11.5px; color: var(--muted); }
.link-list { margin: 10px 0 0; padding-left: 18px; font-size: 13px; overflow-wrap: anywhere; }
.pay-amt { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 3px; }

/* Đăng nhập thử */
.role-group { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 18px 0 8px; }

/* Phân quyền */
.role-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 12px; }
.role-tab { flex: none; padding: 8px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 13px; }
.role-tab span { margin-left: 4px; color: var(--muted); font-size: 12px; }
.role-tab.on { background: var(--grad); color: #fff; border-color: transparent; }
.role-tab.on span { color: rgba(255, 255, 255, .85); }
.perm-matrix td, .perm-matrix th { padding-top: 10px; padding-bottom: 10px; }
.perm-matrix input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; }
.perm-summary td { font-size: 12px; white-space: nowrap; }
.perm-cell.perm-4 { color: var(--ok); font-weight: 700; }
.perm-cell.perm-1 { color: var(--muted); }
.special-matrix th .cell-sub { font-size: 10.5px; font-weight: 400; white-space: normal; }
.lvl { padding: 4px 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-size: 12px; }
.lvl-all { background: var(--ok-soft); color: var(--ok); border-color: transparent; font-weight: 700; }
.lvl-head { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 700; }
.check-row { display: flex; flex-direction: column; gap: 8px; }
.check-row small { color: var(--muted); font-weight: 400; }
.badges-inline { display: inline-flex; gap: 4px; flex-wrap: wrap; margin-left: 4px; vertical-align: middle; }
.cls-list-2 li { grid-template-columns: minmax(0, 1fr) 110px 70px 34px; }
.cls-list-2 .cls-desc { grid-column: 1 / -1; font-size: 12.5px; }
.cls-list-2 li + li { padding-top: 8px; border-top: 1px dashed var(--line); }
.cf-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.cf-item { padding: 12px; border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; gap: 8px; }
.cf-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cf-row > input { flex: 1 1 220px; min-width: 0; }
.cf-item input:not([type=checkbox]), .cf-item select { padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.cf-opts { width: 100%; }
.cf-tools { display: inline-flex; gap: 2px; margin-left: auto; }
.cf-row-2 { align-items: flex-start; }

/* Điện thoại: mục "Thêm" của thanh tab */
.more-back { display: none; }
@media (max-width: 860px) {
  .more-back { display: block; position: fixed; inset: 0; z-index: 19; background: rgba(15, 16, 36, .35); }
  .more-sheet { position: absolute; left: 10px; right: 10px; bottom: calc(64px + env(safe-area-inset-bottom, 0px)); background: var(--surface); border-radius: 18px;
    box-shadow: var(--shadow); padding: 8px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .more-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 4px; border: 0; border-radius: 12px; background: none; font-size: 12px; cursor: pointer; color: var(--ink); text-align: center; }
  .more-item.on { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
  .fb-msg { max-width: 100%; }
  .cp-side { width: 100%; }
}
.cp-row:disabled { cursor: default; }
.classify .field { align-items: stretch; text-align: left; }
.classify select, .side-block > select, .assign select { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.special-matrix th .cell-sub { color: rgba(255, 255, 255, .72); }
@media (max-width: 560px) {
  .cust-table thead, .cust-table tfoot { display: none; }
  .cust-table, .cust-table tbody { display: block; }
  .cust-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
  .cust-table td { display: block; padding: 0; border: 0; }
  .cust-table td:nth-child(1) { grid-column: 1 / -1; }
  .cust-table td:nth-child(2) { grid-column: 1 / -1; padding-left: 42px; }
  .cust-table td:nth-child(3) { padding-left: 42px; font-size: 12.5px; }
  .cust-table td:nth-child(4) { text-align: right; }
  .cust-table td:nth-child(5) { display: none; }
  .cust-table td:nth-child(7) { grid-column: 1 / -1; padding-left: 42px; font-size: 12.5px; }
  .cust-table td:nth-child(6) { grid-column: 1 / -1; padding-left: 42px; text-align: left; font-size: 12.5px; }
  .cust-table td:nth-child(6):not(:empty)::before { content: "Còn phải thu: "; color: var(--muted); font-family: var(--font-ui); }
}
.zalo-link { display: inline-flex; align-items: center; gap: 4px; margin-top: 3px; padding: 1px 8px; border-radius: 99px; background: #e8f1ff; color: #0068ff; font-size: 11.5px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.zalo-link:hover { background: #d6e7ff; }
.cust-table td .zalo-link { display: flex; width: fit-content; }
.contact-phone { display: block; margin-top: 2px; font-size: 14px; font-weight: 600; }
.contact-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-zalo { background: #0068ff; color: #fff; border-color: #0068ff; text-decoration: none; }
.btn-zalo:hover { background: #0057d6; }

/* ---------- Đợt 2: hồ sơ kỹ thuật ---------- */
.tech { border-top: 4px solid var(--g-to); }
.tech-steps { list-style: none; margin: 4px 0 14px; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; counter-reset: ts; }
.ts { display: flex; align-items: flex-start; gap: 8px; padding: 10px; border-radius: 12px; background: var(--surface-2); min-width: 0; }
.ts-dot { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--surface); color: var(--muted); border: 1px solid var(--line); }
.ts-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; font-size: 12px; }
.ts-text strong { font-size: 12.5px; line-height: 1.3; }
.ts-text span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.ts-done .ts-dot { background: var(--ok); color: #fff; border-color: transparent; }
.ts-now { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.ts-now .ts-dot { background: var(--grad); color: #fff; border-color: transparent; }
.tech-return { padding: 10px 14px; border-radius: 12px; background: var(--bad-soft); color: var(--ink); margin-bottom: 12px; border-left: 4px solid var(--bad); }
.tech-return strong { color: var(--bad); }
.tech-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 14px; }
.tech-block { border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.tech-block-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.tech-block .link-list { margin: 0; }
.tech-block .muted { color: var(--muted); list-style: none; margin-left: -18px; }
.tf-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.tf { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); min-width: 0; }
.tf-ico { flex: none; width: 40px; height: 32px; border-radius: 6px; display: grid; place-items: center; font-size: 10px; font-weight: 800; letter-spacing: .03em; background: #fde8e6; color: #b42318; }
.tf-source .tf-ico { background: var(--accent-soft); color: var(--accent); }
.tf-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tf-main a { font-weight: 600; overflow-wrap: anywhere; color: var(--ink); }
.tech-upload { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 4px; border-top: 1px dashed var(--line); }
.tech-upload .link-add { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 6px; }
.tech-upload .link-add input { flex: 1 1 200px; min-width: 0; padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.file-btn { position: relative; overflow: hidden; cursor: pointer; }
.file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.tech-old summary, .tech-history summary { cursor: pointer; font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 6px; }
.tech-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.tech-actions input { flex: 1 1 220px; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.tech-actions .note { margin: 0; margin-right: auto; }
.tl-bad .tl-what strong { color: var(--bad); }
.dossier-sec .opt { font-size: 11px; font-weight: 600; color: var(--muted); margin-left: 6px; text-transform: uppercase; letter-spacing: .04em; }
@media (max-width: 860px) {
  .tech-steps { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .ts { padding: 8px 10px; align-items: center; }
  .tech-grid { grid-template-columns: minmax(0, 1fr); }
  .tech-actions { justify-content: stretch; }
  .tech-actions .btn { flex: 1 1 auto; }
}
.tech-block .link-list { list-style: none; padding-left: 0; display: flex; flex-direction: column; gap: 4px; } .tech-block .muted { margin-left: 0; }
.due-auto { font-size: 16px; padding: 6px 0 2px; }

/* ---------- Đợt 3: khuyến mại theo nhóm khách, mua hàng, tạm ứng ---------- */
.note-ok { color: var(--ok); }
.benefit { display: inline-flex; padding: 2px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--accent); max-width: 220px; line-height: 1.4; }
.benefit-amount { background: var(--ok-soft); color: var(--ok); }
.benefit-gift { background: var(--warn-soft); color: var(--warn); }
.gift-dd { font-weight: 600; color: var(--warn); }

.po-list, .adv-list { display: flex; flex-direction: column; gap: 10px; }
.po, .adv { border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; background: var(--surface); min-width: 0; }
.po-late { border-left-color: var(--bad); background: linear-gradient(90deg, var(--bad-soft), var(--surface) 40%); }
.po-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.po-title { font-weight: 700; text-align: left; }
.po-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; color: var(--muted); font-size: 13px; }
.po-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.po-amt { font-weight: 700; white-space: nowrap; }
.po-link { color: var(--accent); font-size: 13px; }
.po-detail { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.po-actions { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.po-lines { display: flex; flex-direction: column; gap: 6px; }
.po-line { display: grid; grid-template-columns: minmax(0, 3fr) 80px 70px 120px 120px 36px; gap: 8px; align-items: center; }
.po-line-head { font-size: 12px; font-weight: 600; color: var(--muted); }
.po-line input, .po-line select { width: 100%; min-width: 0; }
.rcv-input { width: 90px; text-align: right; }
.adv-cho_duyet { border-left-color: var(--warn); }
.adv-tra_lai { border-left-color: #f08c00; }
.adv-da_duyet { border-left-color: var(--accent); }
.adv-da_hoan_ung { border-left-color: var(--ok); }
.adv-tu_choi { border-left-color: var(--bad); opacity: .8; }
.adv-items { display: flex; flex-direction: column; gap: 6px; }
.adv-item { display: grid; grid-template-columns: minmax(0, 3fr) 70px 70px 120px 36px; gap: 8px; align-items: center; }
.adv-item input { width: 100%; min-width: 0; }
@media (max-width: 860px) {
  .po-line, .adv-item { grid-template-columns: 1fr 1fr; }
  .po-line > :first-child, .adv-item > :first-child { grid-column: 1 / -1; }
  .po-line-head { display: none; }
}
.po-line .po-link { grid-column: 1 / -1; margin-top: -2px; }
.po-lines > .btn, .adv-items > .btn { align-self: flex-start; }
.po-list, .adv-list { list-style: none; padding: 0; margin: 0; }
.camp-table td:first-child { min-width: 240px; }
.camp-table td:nth-child(2) { min-width: 180px; }
.camp-table td:nth-child(4) { white-space: nowrap; }

/* ---------- 3.1: bộ phận & chức danh, quyền phê duyệt ---------- */
.appr-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr)); gap: 14px; }
.appr { display: flex; flex-direction: column; gap: 12px; }
.appr-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.appr-head h3 { margin: 0 0 2px; font-size: 15px; }
.appr-body { display: flex; flex-direction: column; gap: 12px; }
.appr-body .field-label { display: block; margin-bottom: 6px; }
.appr-body .chips { margin-bottom: 8px; }
.appr-add { width: 100%; max-width: 320px; }
.org-table input, .org-table select { width: 100%; min-width: 140px; }
.org-table td { vertical-align: top; }

/* ---------- 3.2: nhóm phân quyền ---------- */
.role-tab-add { border-style: dashed; color: var(--accent); }
.pg-head { gap: 12px; flex-wrap: wrap; }
.pg-name { font-size: 18px; font-weight: 700; border: 1px solid transparent; border-radius: var(--r-sm); padding: 6px 8px; background: transparent; min-width: 0; flex: 1 1 240px; }
.pg-name:hover, .pg-name:focus { border-color: var(--line); background: var(--surface); }
.pg-desc { width: 100%; margin: 4px 0 14px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.pg-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.pg-assign { display: flex; flex-direction: column; gap: 8px; }
.pg-assign .field-label small { font-weight: 400; color: var(--muted); }
.pg-link { display: block; text-align: left; color: var(--accent); font-size: 13px; }
@media (max-width: 860px) { .pg-grid { grid-template-columns: 1fr; } }

/* ---------- 3.2: kích hoạt bằng mã ---------- */
.act-title { font-size: 18px; margin: 0; }
.act-links { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; font-size: 13px; }
.act-link { align-self: center; font-size: 13px; color: var(--accent); }
.otp-input { font-family: var(--mono, ui-monospace, monospace); font-size: 22px !important; letter-spacing: .4em; text-align: center; }
.msg-preview { border-radius: 16px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.msg-preview p { margin: 0; font-size: 14px; line-height: 1.45; }
.msg-zalo { background: #e8f1ff; border-color: #c7dcff; }
.msg-app { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #0068ff; }
.msg-sms .msg-app { color: var(--ok); }
.msg-email p { white-space: pre-line; overflow-wrap: anywhere; }
.msg-email .msg-app { color: var(--accent); }
.msg-note { font-size: 11.5px; color: var(--muted); }
.role-card-invited { border-style: dashed; opacity: .9; }
.otp-log { margin-top: 12px; font-size: 13px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .msg-zalo { background: #15233d; border-color: #24406e; } }
:root[data-theme="dark"] .msg-zalo { background: #15233d; border-color: #24406e; }

/* ---------- 3.2: vật tư, bảng giá NCC, xuất đơn ---------- */
.tech-mats { margin-top: 14px; }
.mats-table input, .cat-table input, .needs-table input, .needs-table select { width: 100%; min-width: 0; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.mats-table td:first-child { min-width: 200px; }
.cat-table td:nth-child(2) { min-width: 200px; }
.cat-unit { max-width: 70px; }
.needs-table td:nth-child(2) { min-width: 200px; }
.needs-table select { min-width: 220px; }
.needs-qty { max-width: 80px; text-align: right; }
.needs-price { max-width: 110px; text-align: right; }
.needs-bar { flex-wrap: wrap; gap: 10px; }
.needs-bar .admin-actions { margin-left: auto; }
.export-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin: 12px 0; }
.export-grid .btn { width: 100%; }
.mats-table { min-width: 860px; }
.mats-table td:nth-child(1) { width: 26%; } .mats-table td:nth-child(2) { width: 22%; }
.mats-table td:nth-child(3) input, .mats-table td:nth-child(4) input { min-width: 64px; }
.mats-table td:nth-child(5) input { min-width: 100px; } .mats-table td:nth-child(6) input { min-width: 120px; }
.cat-table { min-width: 900px; }
.needs-table { min-width: 900px; }
.role-tabs-wrap { flex-wrap: wrap; overflow: visible; }
#pg-who { min-width: 260px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }

/* Phân trang */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 4px; font-size: 13px; color: var(--muted); }
.pager-info { margin-right: auto; font-variant-numeric: tabular-nums; }
.pager-page { font-variant-numeric: tabular-nums; }
.bell-more { display: block; width: 100%; padding: 10px 8px; text-align: center; color: var(--accent); font-size: 13px; }

/* ---------- Mua hàng: hàng cần mua theo công trình, sản phẩm NCC ---------- */
.kpis-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.buy-progress { display: inline-flex; align-items: center; gap: 8px; min-width: 110px; }
.link-accent { color: var(--accent); font-weight: 600; }
.prod-filters { justify-content: flex-start; gap: 8px; }
.prod-filters .search { flex: 1 1 220px; }
.prod-filters select { min-height: 38px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); padding: 0 10px; }
@media (max-width: 760px) { .kpis-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Chi tiết công trình: tab theo giai đoạn ---------- */
.page-eyebrow { display: block; margin-bottom: 4px; font-size: 13px; font-weight: 600; color: var(--accent); letter-spacing: .02em; }
.meta-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
.meta-line > span:not(:first-child)::before { content: "·"; margin-right: 14px; margin-left: -10px; color: var(--line); }
.panel.panel-steps { padding-bottom: 0; }
.step-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; border: 0; background: none; padding: 0; cursor: pointer; color: inherit; font: inherit; }
.step-btn:hover .step-label { color: var(--accent); }
.ptabs { position: relative; display: flex; gap: 4px; margin: 14px -24px 0; padding: 0 16px; border-top: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.ptabs::-webkit-scrollbar { display: none; }
.ptab { position: relative; display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; padding: 13px 12px 12px; border: 0; background: none; cursor: pointer; color: var(--muted); font: 500 14px/1.2 var(--font-ui); white-space: nowrap; border-bottom: 2px solid transparent; }
.ptab:hover { color: var(--ink); }
.ptab-on { color: var(--accent); font-weight: 600; border-bottom-color: var(--accent); }
.ptab-now { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ptab-count { padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font: 600 11.5px/1.5 var(--font-mono); }
.ptab-on .ptab-count { background: var(--accent-soft); color: var(--accent); }
.detail-main .empty { padding: 14px 12px; font-size: 13.5px; }
@media (max-width: 860px) { .ptabs { margin: 12px -18px 0; padding: 0 8px; } }
@media (max-width: 560px) {
  .ptab { padding: 12px 9px 11px; font-size: 13.5px; }
  .meta-line { font-size: 13px; gap: 2px 12px; }
  .meta-line > span:not(:first-child)::before { display: none; }
}

/* ---------- Bảng thành thẻ trên điện thoại (hàng cần mua, đơn mua, vật tư, biên bản bàn giao) ---------- */
.stack-only { display: none; }
@media (max-width: 640px) {
  .table.table-stack, .table-stack.needs-table, .table-stack.mats-table { min-width: 0; }
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody { display: block; }
  .table-stack tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 14px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
  .table-stack tr:last-child { border-bottom: 0; }
  .table-stack td { display: block; padding: 0 !important; border: 0 !important; text-align: left !important; min-width: 0; width: auto !important; }
  .table-stack td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 2px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
  .table-stack .stack-title { grid-column: 1 / -1; font-weight: 600; }
  .table-stack .stack-hide { display: none; }
  .table-stack .stack-only { display: inline; }
  .table-stack .cell-sub.stack-only { display: block; }
  .table-stack td input:not([type=checkbox]), .table-stack td select { width: 100%; min-width: 0 !important; max-width: none !important; }
  .table-stack .stack-del { position: absolute; right: 0; top: 8px; }
  .mats-edit tr { position: relative; padding-right: 36px; grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Hàng cần mua: ô chọn | tên + trạng thái / SL · đơn giá / nhà cung cấp */
  .needs-table tr { grid-template-columns: 26px minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "sel name name" ". st st" ". pick pick" ". qty price"; }
  .needs-table:not(:has(.nd-sel)) tr { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "name name" "st st" "qty price"; }
  .needs-table .nd-sel { grid-area: sel; padding-top: 2px !important; }
  .needs-table .nd-name { grid-area: name; }
  .needs-table .nd-st { grid-area: st; }
  .needs-table .nd-st:empty { display: none; }
  .needs-table .nd-qty { grid-area: qty; }
  .needs-table .nd-qty input { display: inline-block; width: 70px !important; margin-right: 6px; }
  .needs-table .nd-qty .cell-sub { display: inline; }
  .needs-table .nd-price { grid-area: price; }
  .needs-table .nd-pick { grid-area: pick; }
  .needs-bar .admin-actions { margin-left: 0; width: 100%; display: flex; flex-wrap: wrap; gap: 8px; }
  .needs-bar .admin-actions .btn-primary { flex: 1 1 100%; }

  /* Biên bản bàn giao: không gian nhỏ phía trên, hạng mục + nút Đạt, tồn đọng bên dưới */
  .handover-table tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "group ok" "name ok" "issue issue"; gap: 2px 12px; }
  .handover-table .ho-group { grid-area: group; font-size: 11.5px; color: var(--muted); }
  .handover-table .ho-name { grid-area: name; font-weight: 600; }
  .handover-table .ho-ok { grid-area: ok; align-self: center; }
  .handover-table .ho-issue { grid-area: issue; margin-top: 6px; }
  .ho-ok-label { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 99px; font-size: 13px; font-weight: 600; cursor: pointer; }
  .ho-ok-label:has(input:checked) { border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); background: color-mix(in srgb, var(--ok) 10%, var(--surface)); color: var(--ok); }
  .handover-table .row-issue .ho-ok-label { color: var(--bad); }
  .table-stack tr.row-issue { margin: 0 -8px; padding-left: 10px; padding-right: 10px; border-radius: var(--r-sm); background: color-mix(in srgb, var(--bad-soft) 60%, transparent); }
  .table-stack .row-issue td { background: none; }
  .table-stack tr.row-off { opacity: .6; }

  /* Bản xem biên bản: bảng vừa màn hình */
  .paper { padding: 14px 10px; font-size: 13px; }
  .paper-title { font-size: 16px; }
  .paper-table { font-size: 12px; }
  .paper-table th, .paper-table td { padding: 4px 5px; }
  .paper-sign { gap: 10px; }
}

/* ---------- Cột phải công trình: phụ trách gọn, thanh toán / chi phí / báo giá gập lại ---------- */
.detail-side { gap: 12px; }
.panel.team-panel { padding: 16px 20px; }
.team-panel .panel-head { margin-bottom: 8px; }
.team { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 6px 10px; margin: 0; font-size: 13.5px; }
.team dt { color: var(--muted); font-size: 12.5px; }
.team dd { margin: 0; min-width: 0; }
.team-panel .watchers .note:last-child { display: none; }
.panel.fold { padding: 0; }
.fold-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; cursor: pointer; list-style: none; user-select: none; }
.fold-head::-webkit-details-marker { display: none; }
.fold-head::after { content: ""; width: 8px; height: 8px; margin-left: 2px; flex: none; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg) translateY(-3px); transition: transform .15s; }
.fold[open] > .fold-head::after { transform: rotate(-135deg) translate(-2px, -1px); }
.fold-title { font-size: 15px; font-weight: 600; white-space: nowrap; }
.fold-sum { margin-left: auto; font-size: 12.5px; font-weight: 600; color: var(--muted); text-align: right; min-width: 0; }
.fold-meter { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 4px; min-width: 110px; }
.fold-meter .progress { flex: none; width: 110px; height: 5px; }
.fold-body { padding: 0 20px 18px; display: flex; flex-direction: column; gap: 12px; }
.fold[open] > .fold-head { padding-bottom: 10px; }
.fold-actions { display: flex; justify-content: flex-end; }
.pay-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.pay-row { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.pay-row:first-child { padding-top: 0; }
.pay-main { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.pay-state { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; }
.pay-state .pay-form { margin-left: auto; }

/* ---------- Menu tài khoản (ảnh đại diện góc phải / chân menu trái) ---------- */
.acct-btn { display: inline-grid; place-items: center; padding: 2px; border: 0; border-radius: 99px; background: none; cursor: pointer; }
.acct-btn:hover .avatar, .acct-btn[aria-expanded=true] .avatar { box-shadow: 0 0 0 3px var(--accent-soft); }
button.side-foot { width: calc(100% - 28px); font: inherit; color: inherit; text-align: left; cursor: pointer; }
button.side-foot:hover { background: var(--accent-soft); }
.side-foot .me { flex: 1; min-width: 0; }
.side-foot > svg { color: var(--muted); }
.acct-back { position: fixed; inset: 0; z-index: 30; }
.acct-menu { position: absolute; top: 60px; right: 16px; width: 300px; max-width: calc(100vw - 32px); background: var(--surface); border-radius: 16px; box-shadow: 0 12px 40px rgba(15, 16, 36, .18); border: 1px solid var(--line); padding: 8px; }
.acct-head { display: flex; align-items: center; gap: 12px; padding: 10px 10px 12px; }
.acct-head .me { display: flex; flex-direction: column; min-width: 0; }
.acct-head .me span { font-size: 12.5px; color: var(--muted); }
.acct-info { display: grid; grid-template-columns: 80px minmax(0, 1fr); gap: 4px 10px; margin: 0 0 6px; padding: 10px; border-radius: 10px; background: var(--surface-2); font-size: 13px; }
.acct-info dt { color: var(--muted); font-size: 12px; }
.acct-info dd { margin: 0; overflow-wrap: anywhere; }
.acct-items { display: flex; flex-direction: column; }
.acct-item { display: flex; align-items: center; gap: 12px; padding: 11px 10px; border: 0; border-radius: 10px; background: none; color: var(--ink); font: 500 14px/1.2 var(--font-ui); text-align: left; cursor: pointer; }
.acct-item svg { color: var(--muted); flex: none; }
.acct-item:hover { background: var(--surface-2); }
.acct-out, .acct-out svg { color: var(--bad); }
@media (min-width: 861px) { .acct-menu { top: 64px; } .acct-menu-side { top: auto; right: auto; left: 14px; bottom: 96px; } }
@media (max-width: 860px) {
  .acct-back { background: rgba(15, 16, 36, .35); }
  .acct-menu { top: auto; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); width: auto; max-width: none; border-radius: 18px; padding: 10px; }
  .acct-item { padding: 14px 10px; font-size: 15px; }
}

/* Hướng dẫn lần đầu đăng nhập */
.tour { position: fixed; inset: 0; z-index: 60; }
.tour-dim { position: absolute; inset: 0; background: rgba(15, 16, 36, .55); }
.tour-hole { position: fixed; border-radius: 14px; box-shadow: 0 0 0 9999px rgba(15, 16, 36, .55), 0 0 0 3px var(--accent); transition: top .25s ease, left .25s ease, width .25s ease, height .25s ease; pointer-events: none; }
.tour-card { position: fixed; width: min(340px, calc(100vw - 24px)); background: var(--surface); color: var(--ink); border-radius: 18px; padding: 18px 18px 14px; box-shadow: 0 18px 50px rgba(20, 21, 42, .28); outline: none; }
.tour-card h2 { font-size: 18px; margin: 2px 0 6px; }
.tour-card p { margin: 0 0 12px; color: var(--muted); line-height: 1.55; }
.tour-count { font-size: 12px; font-weight: 600; letter-spacing: .04em; color: var(--accent); }
.tour-dots { display: flex; gap: 5px; margin-bottom: 12px; }
.tour-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.tour-dots span.on { background: var(--accent); width: 16px; border-radius: 3px; }
.tour-actions { display: flex; align-items: center; gap: 8px; }
.tour-spacer { flex: 1; }
@media (prefers-reduced-motion: reduce) { .tour-hole { transition: none; } }

/* Nhật ký thay đổi (Quản trị): gọn — chữ nhỏ, một dòng mỗi thay đổi, mở chi tiết ngay dưới dòng */
.audit-filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 8px; }
.audit-filters .search { flex: 1 1 220px; max-width: 320px; padding: 6px 10px; font-size: 13px; }
.audit-filters select { padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); font-size: 13px; min-width: 0; }
.audit-panel { padding: 4px 6px; }
.audit-table { font-size: 12.5px; min-width: 560px; }
.audit-table td { padding: 5px 6px; vertical-align: middle; }
.audit-table td.mono { white-space: nowrap; color: var(--muted); font-size: 11.5px; }
.audit-table .badge { padding: 0 7px; font-size: 11px; }
.audit-table tr.row-on td { background: var(--accent-soft); }
.audit-table tr.audit-open td { background: var(--surface-2); padding: 6px 10px 8px; }
.audit-ent { color: var(--muted); font-size: 11.5px; margin-right: 2px; }
.audit-sum { color: var(--muted); }
.audit-diff { display: grid; gap: 3px; }
.audit-diff-row { display: grid; grid-template-columns: minmax(120px, 220px) minmax(0, 1fr); gap: 8px; align-items: baseline; }
.audit-field { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.audit-old, .audit-new { display: inline-block; border-radius: 4px; padding: 0 5px; margin-right: 4px; text-decoration: none; overflow-wrap: anywhere; }
.audit-old { background: var(--bad-soft); color: var(--bad); text-decoration: line-through; }
.audit-new { background: var(--ok-soft); color: var(--ok); }
@media (max-width: 640px) { .audit-diff-row { grid-template-columns: minmax(0, 1fr); gap: 0; } }

/* Sao lưu (Quản trị): 3 ô trạng thái + bảng các lần chạy, cùng cỡ chữ gọn với tab Nhật ký */
.backup-alert { margin: 10px 0 0; padding: 7px 12px; border-radius: var(--r-sm); background: var(--bad-soft); color: var(--bad); font-size: 13px; }
.backup-alert-warn { background: var(--warn-soft); color: var(--warn); }
.backup-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 12px 0 10px; }
@media (max-width: 760px) { .backup-tiles { grid-template-columns: minmax(0, 1fr); } }
.backup-tile { padding: 10px 14px; display: grid; gap: 2px; min-width: 0; }
.backup-tile-k { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.backup-tile-k .badge { padding: 0 7px; font-size: 11px; letter-spacing: 0; text-transform: none; }
.backup-tile-v { font-size: 14px; font-weight: 600; }
.backup-table { font-size: 12.5px; min-width: 560px; }
.backup-table td { padding: 5px 6px; vertical-align: middle; }
.backup-table td.mono { white-space: nowrap; color: var(--muted); font-size: 11.5px; }
.backup-table .badge { padding: 0 7px; font-size: 11px; }
.backup-empty { padding: 14px 16px; margin-top: 12px; font-size: 13px; }
.backup-empty p { margin: 0; }
