:root {
    --crm-navy: #2f3b63;
    --crm-navy-deep: #273255;
    --crm-orange: #f39221;
    --crm-orange-soft: #fff4e8;
    --crm-bg: #f4f6f9;
    --crm-card: #ffffff;
    --crm-text: #1f2a44;
    --crm-muted: #7b8499;
    --crm-border: #e6ebf2;
    --crm-line-soft: #eef1f6;
    --crm-card-pad-y: 12px;
    --crm-card-pad-x: 14px;
    --crm-radius: 10px;
    --crm-shadow: 0 1px 2px rgba(31, 42, 68, 0.04), 0 8px 24px rgba(31, 42, 68, 0.04);
    --crm-select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4.2 6.2L8 10l3.8-3.8' stroke='%238892a6' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--crm-text);
    background: var(--crm-bg);
    font-family: "Segoe UI", Tahoma, sans-serif;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
.crm-muted { color: var(--crm-muted); }

/* Auth */
.crm-auth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #1d2748, #33416b);
}
.crm-login-wrap {
    width: calc(100% - 32px);
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}
.crm-login-card {
    width: 100%;
    background: #fff;
    border-radius: 14px;
    padding: 36px;
    box-shadow: 0 24px 60px rgba(0,0,0,.28);
}
.crm-login-card h1 { margin: 0; font-size: 24px; }
.crm-login-card .crm-muted { margin: 8px 0 24px; }
.crm-login-card label { display: block; margin: 14px 0 6px; font-size: 13px; font-weight: 700; }
.crm-login-card input {
    width: 100%;
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    padding: 11px 12px;
}
.crm-login-card form > button {
    width: 100%;
    margin-top: 22px;
    border: 0;
    border-radius: 8px;
    background: var(--crm-orange);
    color: #fff;
    font-weight: 700;
    padding: 12px 16px;
    cursor: pointer;
}
.crm-check { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--crm-muted); }
.crm-check input { width: auto; }
.crm-error { color: #d64545; font-size: 13px; margin: 6px 0 0; }
.crm-brand-login {
    display: flex;
    align-items: center;
    justify-content: center;
}
.crm-brand-login .crm-logo-full {
    width: 180px;
    max-width: 100%;
    height: auto;
    display: block;
}
.crm-logo-full {
    width: 220px;
    max-width: 100%;
    height: auto;
    display: block;
}

/* App shell — viewport locked; only .crm-main scrolls */
html, body.crm-app {
    height: 100%;
    overflow: hidden;
}
.crm-app {
    min-height: 100vh;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--crm-bg);
    overflow: hidden;
}

/* ===== Top menu bar (thay sidebar cũ) ===== */
.crm-topnav {
    flex-shrink: 0;
    position: relative;
    overflow: visible;
    padding: 10px 24px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfbfe 100%);
    border-bottom: 1px solid var(--crm-border);
    box-shadow: 0 6px 20px -14px rgba(31, 42, 68, .18);
    z-index: 1040;
}
.crm-topnav::before,
.crm-topnav::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(50px);
    pointer-events: none;
    z-index: 0;
}
.crm-topnav::before { width: 280px; height: 280px; background: var(--crm-orange); opacity: .13; top: -200px; left: 18%; }
.crm-topnav::after { width: 260px; height: 260px; background: #4f8bff; opacity: .11; top: -190px; right: 22%; }
.crm-topnav-inner {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 18px;
}
.crm-brand { display: flex; align-items: center; gap: 10px; padding-right: 6px; flex-shrink: 0; }
.crm-brand-logo {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: #fff;
    border: 1px solid var(--crm-border);
    box-shadow: 0 1px 4px rgba(31, 42, 68, .08);
    object-fit: contain;
}
.crm-brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.crm-brand-text b { color: var(--crm-text); font-size: 14.5px; font-weight: 800; letter-spacing: .01em; }
.crm-brand-text span { color: var(--crm-muted); font-size: 10.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; }

.crm-pillnav {
    display: flex;
    align-items: center;
    gap: 7px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
}
.crm-pillnav::-webkit-scrollbar { display: none; }
.crm-pill {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px 15px 6px 6px;
    border-radius: 999px;
    background: rgba(47, 59, 99, .04);
    backdrop-filter: blur(10px) saturate(160%);
    -webkit-backdrop-filter: blur(10px) saturate(160%);
    border: 1px solid rgba(47, 59, 99, .07);
    color: var(--crm-muted);
    font-weight: 700;
    font-size: 13.5px;
    white-space: nowrap;
    transition: background .2s, border-color .2s, color .2s, box-shadow .2s, transform .2s;
}
.crm-pill:hover { background: rgba(47, 59, 99, .08); border-color: rgba(47, 59, 99, .14); color: var(--crm-text); transform: translateY(-1px); }
.crm-pill-ico {
    width: 27px;
    height: 27px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 12px;
    background: color-mix(in srgb, var(--accent) 16%, #fff);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent);
    color: var(--accent);
    transition: background .2s, box-shadow .2s, transform .2s;
}
.crm-pill.is-active {
    background: color-mix(in srgb, var(--accent) 10%, #fff);
    border-color: color-mix(in srgb, var(--accent) 32%, transparent);
    color: var(--crm-navy);
    box-shadow: 0 10px 22px -12px color-mix(in srgb, var(--accent) 60%, transparent), 0 2px 8px -3px rgba(31, 42, 68, .14);
    transform: translateY(-1px);
}
.crm-pill.is-active .crm-pill-ico {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 3px 10px -2px color-mix(in srgb, var(--accent) 60%, transparent), inset 0 0 0 1px rgba(255, 255, 255, .5);
    transform: scale(1.04);
}
.crm-pill.is-disabled { opacity: .5; cursor: not-allowed; }

.crm-topnav-actions { position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.crm-icon-btn {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: 999px;
    background: rgba(47, 59, 99, .04);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(47, 59, 99, .07);
    color: var(--crm-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s, border-color .2s, transform .2s;
}
.crm-icon-btn:hover { background: rgba(47, 59, 99, .08); border-color: rgba(47, 59, 99, .14); color: var(--crm-text); transform: translateY(-1px); }
.crm-profile-menu {
    position: relative;
}
.crm-profile {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 5px 13px 5px 6px;
    border: 1px solid rgba(47, 59, 99, .07);
    background: rgba(47, 59, 99, .04);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    cursor: pointer;
    border-radius: 999px;
    transition: background .2s, border-color .2s;
}
.crm-profile:hover { background: rgba(47, 59, 99, .08); border-color: rgba(47, 59, 99, .14); }
.crm-profile-menu.is-open .crm-profile { background: rgba(47, 59, 99, .08); border-color: rgba(47, 59, 99, .14); }
.crm-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(140deg, var(--crm-orange), #d97a0e);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    flex-shrink: 0;
    overflow: hidden;
    object-fit: cover;
    box-shadow: 0 2px 8px -2px rgba(243, 146, 33, .55);
}
img.crm-avatar {
    padding: 0;
    background: #e8ecf3;
}
.crm-profile-text {
    text-align: left;
}
.crm-profile strong { display: block; font-size: 14px; line-height: 1.2; color: var(--crm-text); }
.crm-profile small { color: var(--crm-muted); font-size: 12px; }
.crm-profile-caret {
    color: #8a94ab;
    font-size: 11px;
    margin-left: 2px;
    transition: transform .15s ease;
}
.crm-profile-menu.is-open .crm-profile-caret { transform: rotate(180deg); }
.crm-profile-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 220px;
    background: #fff;
    border: 1px solid var(--crm-border);
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(31, 42, 68, 0.12);
    padding: 8px;
    z-index: 1100;
}
.crm-profile-dropdown[hidden] { display: none !important; }
.crm-profile-dropdown-label {
    padding: 6px 10px 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #93a0b8;
}
.crm-profile-dropdown-item {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 0;
    background: transparent;
    border-radius: 8px;
    padding: 9px 10px;
    color: var(--crm-text);
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}
.crm-profile-dropdown-main {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.crm-flag {
    width: 20px;
    height: 14px;
    object-fit: cover;
    border-radius: 2px;
    border: 1px solid rgba(31, 42, 68, 0.12);
    flex-shrink: 0;
}
.crm-profile-dropdown-item:hover { background: #f4f6f9; }
.crm-profile-dropdown-item.is-active { color: var(--crm-orange); }
.crm-profile-dropdown-item.is-danger {
    justify-content: flex-start;
    color: #c24141;
}
.crm-profile-dropdown-item.is-danger i { width: 16px; }

.crm-main {
    flex: 1;
    min-height: 0;
    padding: 14px 24px 28px;
    overflow-x: hidden;
    overflow-y: auto;
}

/* ===== Submenu bar (breadcrumb + tiêu đề trang / tab — thay cho phần trong .crm-main cũ) ===== */
.crm-submenu {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    background: var(--crm-card);
    border-bottom: 1px solid var(--crm-border);
}
.crm-submenu-inner {
    padding: 14px 24px 0;
}

.crm-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 28px;
    color: var(--crm-muted);
    font-size: 13px;
    line-height: 1;
    margin: 0 0 8px;
}
.crm-breadcrumb-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    border: 1px solid var(--crm-border);
    border-radius: 6px;
    background: #fff;
    color: #8a93a8;
    text-decoration: none;
    line-height: 0;
}
.crm-breadcrumb-back i {
    font-size: 11px;
    line-height: 1;
    width: 11px;
    text-align: center;
}
.crm-breadcrumb-back:hover {
    color: var(--crm-orange);
    border-color: #f0c89a;
    background: #fff8f0;
}
.crm-breadcrumb-trail {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0 2px;
    min-width: 0;
    line-height: 26px;
}
.crm-breadcrumb a { color: inherit; }
.crm-breadcrumb a:hover { color: var(--crm-orange); }
.crm-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}
.crm-page-header h1 {
    margin: 0;
    font-size: 28px;
    font-weight: 800;
}
.crm-page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.crm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid transparent;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    background: #fff;
    color: var(--crm-text);
    white-space: nowrap;
}
.crm-btn-primary { background: var(--crm-orange); color: #fff; }
.crm-btn-danger {
    background: #c24141;
    border-color: #c24141;
    color: #fff;
}
.crm-btn-danger:hover { background: #a83434; border-color: #a83434; color: #fff; }
.crm-btn-outline-orange {
    border-color: var(--crm-orange);
    color: var(--crm-orange);
    background: #fff;
}
.crm-btn-light { background: #fff; border-color: var(--crm-border); color: #5b6680; }
.crm-btn-icon {
    width: 36px;
    padding: 0;
}
.crm-confirm-dialog {
    max-width: 420px;
}
.crm-confirm {
    position: relative;
    border: 1px solid var(--crm-border);
    border-radius: 12px;
    box-shadow: 0 12px 36px rgba(31, 42, 68, 0.12);
    overflow: hidden;
    background: #fff;
}
.crm-confirm-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    opacity: .45;
}
.crm-confirm-close:hover { opacity: .8; }
.crm-confirm-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 22px 28px 0;
}
.crm-confirm-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    margin-bottom: 10px;
}
.crm-confirm-icon.is-danger {
    background: #fff5f5;
    color: #c24141;
    border: 1px solid #f0c4c4;
}
.crm-confirm-icon.is-warning {
    background: #fff4e8;
    color: #b86a10;
    border: 1px solid #f0c089;
}
.crm-confirm-icon.is-info {
    background: #f4f6f9;
    color: #5b6b8c;
    border: 1px solid var(--crm-border);
}
.crm-confirm-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--crm-text);
    margin: 0;
    line-height: 1.35;
}
.crm-confirm-body {
    padding: 10px 28px 18px;
    text-align: center;
}
.crm-confirm-message {
    font-size: 13.5px;
    line-height: 1.55;
    color: #667085;
    font-weight: 500;
    margin: 0 auto;
    max-width: 32em;
}
.crm-confirm-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 4px 28px 20px;
}
.crm-confirm-footer .crm-btn {
    width: 100%;
    justify-content: center;
}
.crm-confirm-footer .crm-btn-light {
    background: #eef1f6;
    border-color: #eef1f6;
    color: #5b6680;
}
.crm-confirm-footer .crm-btn-light:hover {
    background: #f7f8fb;
    border-color: #e6ebf2;
    color: #3f4a63;
}

.crm-card {
    background: var(--crm-card);
    border: 1px solid var(--crm-line-soft);
    border-radius: var(--crm-radius);
    box-shadow: var(--crm-shadow);
    padding: var(--crm-card-pad-y) var(--crm-card-pad-x);
    margin-bottom: 14px;
}
/* Đường dưới tiêu đề: full-width card (âm padding). Phân cách nội dung dùng .is-section-start — vẫn inset. */
.crm-card-title {
    margin: calc(var(--crm-card-pad-y) * -1) calc(var(--crm-card-pad-x) * -1) var(--crm-card-pad-y);
    padding: var(--crm-card-pad-y) var(--crm-card-pad-x) 10px;
    border-bottom: 1px solid var(--crm-line-soft);
    font-size: 15px;
    font-weight: 800;
    line-height: 1.3;
}
.crm-card-title.is-with-help {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.req { color: #e14b4b; }

.crm-filter-card {
    padding: 0;
    overflow: hidden;
    border-radius: var(--crm-radius);
}
.crm-filter-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    background: #fff;
}
.crm-filter-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
    margin-left: auto;
}
.crm-filter-actions .crm-btn-sm {
    height: 36px;
}
.crm-search-wrap {
    flex: 0 1 460px;
    width: 100%;
    max-width: 460px;
    position: relative;
}
.crm-search-wrap i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #9aa3b8;
    pointer-events: none;
}
.crm-search-wrap input {
    width: 100%;
    height: 36px;
    border: 1px solid var(--crm-border);
    border-radius: 10px;
    padding: 0 14px 0 38px;
    background: #fff;
    color: var(--crm-text);
}
.crm-search-wrap input:focus {
    outline: none;
    border-color: #f0c089;
    box-shadow: 0 0 0 3px rgba(243, 146, 33, 0.12);
}
.crm-filter-badge {
    min-width: 20px;
    height: 20px;
    border-radius: 999px;
    background: var(--crm-orange);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}
.crm-filter-select {
    width: 100%;
    height: 36px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 0 34px 0 12px;
    background-color: #fff;
    background-image: var(--crm-select-chevron);
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px;
    color: var(--crm-text);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.2;
    box-shadow: 0 1px 2px rgba(31, 42, 68, 0.04);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.crm-filter-select::-ms-expand { display: none; }
.crm-filter-select:hover {
    border-color: #cfd8e6;
    background-color: #fbfcfe;
}
.crm-filter-select.is-active {
    border-color: rgba(243, 146, 33, 0.55);
    color: var(--crm-text);
    background-color: #fffaf4;
    box-shadow: 0 0 0 3px rgba(243, 146, 33, 0.1);
}
.crm-filter-select:focus {
    outline: none;
    border-color: rgba(243, 146, 33, 0.65);
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(243, 146, 33, 0.14);
}

/* Custom select — list bo góc + đổ bóng (menu gắn body, không bị bảng che) */
.crm-select {
    position: relative;
    display: block;
    width: 100%;
}
.crm-select.is-per-page {
    display: inline-block;
    width: auto;
}
.crm-select > select.crm-select-native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    border: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
}
.crm-select-trigger {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    height: 36px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 0 12px;
    background: #fff;
    color: var(--crm-text);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.2;
    box-shadow: 0 1px 2px rgba(31, 42, 68, 0.04);
    cursor: pointer;
    text-align: left;
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.crm-select.is-per-page .crm-select-trigger {
    height: 30px;
    min-width: 118px;
    border-radius: 8px;
}
.crm-select-trigger:hover {
    border-color: #cfd8e6;
    background: #fbfcfe;
}
/* Select bị khoá: trigger phải TRÔNG và HÀNH XỬ như đã khoá — select gốc bị clip
   nên nếu chỉ disabled ở select thì người dùng vẫn bấm trigger đổi được (UI hiện
   một đằng, form gửi hidden giá trị cũ một nẻo). Đặt sau :hover để thắng specificity. */
.crm-select.is-disabled .crm-select-trigger {
    background: #f5f7fa;
    color: #6b758c;
    border-color: #e8ecf3;
    cursor: not-allowed;
    pointer-events: none;
}
.crm-select.is-disabled .crm-select-caret {
    opacity: .45;
}
.crm-select.is-open .crm-select-trigger,
.crm-select-trigger:focus {
    outline: none;
    border-color: rgba(243, 146, 33, 0.65);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(243, 146, 33, 0.14);
}
.crm-select-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.crm-select-caret {
    flex: 0 0 auto;
    width: 14px;
    height: 14px;
    background: var(--crm-select-chevron) center / 14px no-repeat;
    opacity: .85;
    transition: transform .15s ease;
}
.crm-select.is-open .crm-select-caret {
    transform: rotate(180deg);
}
.crm-select-menu {
    position: fixed;
    z-index: 2300;
    margin: 0;
    padding: 6px;
    list-style: none;
    max-height: min(280px, 50vh);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 10px 28px rgba(31, 42, 68, 0.14);
    display: none;
    box-sizing: border-box;
}
.crm-select-menu.is-open {
    display: block;
}
.crm-select-menu.is-searchable {
    display: none;
    padding: 0;
    min-width: 220px;
}
.crm-select-menu.is-searchable.is-open {
    display: flex;
    flex-direction: column;
}
.crm-select-option {
    display: block;
    width: max-content;
    min-width: 100%;
    box-sizing: border-box;
    border: 0;
    border-radius: 8px;
    padding: 8px 10px;
    background: transparent;
    color: var(--crm-text);
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
}
.crm-select-menu.is-capped .crm-select-option {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}
.crm-select-search {
    flex: 0 0 auto;
    padding: 8px 8px 6px;
    border-bottom: 1px solid #e8edf3;
}
.crm-select-search-input {
    width: 100%;
    height: 34px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0 10px;
    font-size: 13px;
    color: var(--crm-text);
    background: #fff;
}
.crm-select-search-input:focus {
    outline: none;
    border-color: rgba(243, 146, 33, 0.65);
    box-shadow: 0 0 0 3px rgba(243, 146, 33, 0.14);
}
.crm-select-options {
    flex: 1 1 auto;
    overflow: auto;
    max-height: min(240px, 45vh);
    padding: 6px;
    overscroll-behavior: contain;
}
.crm-select-empty,
.crm-select-loading {
    padding: 10px;
    font-size: 13px;
    color: #9aa3b5;
    text-align: center;
}
.crm-select-loading {
    padding: 8px 10px 10px;
    font-size: 12px;
}
.crm-field .crm-select-trigger {
    height: 42px;
    border-radius: 10px;
    padding: 0 12px;
    font-size: 14px;
    box-shadow: 0 1px 2px rgba(31, 42, 68, 0.03);
}
.crm-select-option:hover {
    background: #ffe0b8;
    color: #9a5608;
}
.crm-select-option.is-selected {
    background: var(--crm-orange);
    color: #fff;
    font-weight: 700;
}
.crm-select-option.is-selected:hover {
    background: #e8891a;
    color: #fff;
}
.crm-select-option:disabled {
    color: #9aa3b5;
    cursor: default;
    background: transparent;
}

@media (max-width: 991.98px) {
    .crm-filter-top {
        flex-direction: column;
        align-items: stretch;
    }
    .crm-search-wrap {
        max-width: none;
        flex: 1 1 auto;
    }
    .crm-filter-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

.crm-bulk-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 12px;
    padding: 10px 12px;
    border: 1px solid #f0c089;
    border-radius: 10px;
    background: #fff8f0;
    color: var(--crm-text);
    font-size: 13px;
    font-weight: 600;
}
.crm-bulk-bar[hidden] {
    display: none !important;
}
.crm-bulk-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.crm-toast-stack {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 2200;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(360px, calc(100vw - 32px));
    pointer-events: none;
}
.crm-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 12px 12px 14px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid var(--crm-border);
    box-shadow: 0 12px 32px rgba(31, 42, 68, 0.14);
    color: var(--crm-text);
    transform: translate3d(16px, 0, 0);
    opacity: 0;
    will-change: transform, opacity;
    transition:
        transform .15s cubic-bezier(.22, 1, .36, 1),
        opacity .14s ease-out;
}
.crm-toast.is-in {
    transform: translate3d(0, 0, 0);
    opacity: 1;
}
.crm-toast.is-out {
    transform: translate3d(10px, 0, 0);
    opacity: 0;
    transition:
        transform .12s ease-in,
        opacity .1s ease-in;
}
.crm-toast-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    font-size: 13px;
}
.crm-toast-body {
    flex: 1 1 auto;
    min-width: 0;
    padding-top: 3px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
}
.crm-toast-close {
    border: 0;
    background: transparent;
    color: var(--crm-muted);
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex: 0 0 auto;
}
.crm-toast-close:hover {
    background: #f4f6f9;
    color: var(--crm-text);
}
.crm-toast.is-success {
    border-color: #c8ebd2;
}
.crm-toast.is-success .crm-toast-icon {
    background: #eefaf1;
    color: #1f7a3c;
}
.crm-toast.is-warning {
    border-color: #f0c089;
}
.crm-toast.is-warning .crm-toast-icon {
    background: #fff4e8;
    color: #b86a10;
}
.crm-toast.is-error {
    border-color: #f0c4c4;
}
.crm-toast.is-error .crm-toast-icon {
    background: #fff5f5;
    color: #c24141;
}
.crm-toast.is-info {
    border-color: #d5dde8;
}
.crm-toast.is-info .crm-toast-icon {
    background: #f4f6f9;
    color: #5b6b8c;
}
.crm-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.crm-table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}
.crm-table th {
    background: #f7f8fb;
    color: #5f6b84;
    font-size: 13px;
    font-weight: 700;
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--crm-border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.25;
}
.crm-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--crm-line-soft);
    font-size: 14px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}
.crm-table tbody tr:hover { background: #fbfcfe; }
.crm-table .crm-code {
    color: var(--crm-orange);
    font-weight: 700;
}
.crm-table .crm-check-col {
    width: 44px;
    min-width: 44px;
    max-width: 44px;
    text-align: center;
    padding-left: 8px;
    padding-right: 8px;
}
.crm-table .crm-actions-col {
    width: 88px;
    min-width: 88px;
    max-width: 88px;
    text-align: center;
    padding-left: 8px;
    padding-right: 14px;
}
.crm-table td.crm-actions-col,
.crm-table th.crm-actions-col {
    overflow: visible;
    text-overflow: clip;
}
.crm-actions {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.crm-action-menu {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    margin: 0;
    list-style: none;
    width: max-content;
    padding: 6px;
    border: 1px solid var(--crm-border);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 10px 28px rgba(31, 42, 68, 0.12);
    z-index: 1080;
}
.crm-actions.is-open .crm-action-menu {
    display: block;
}
.crm-action-menu .crm-action-item {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 0;
    border-radius: 8px;
    padding: 7px 12px 7px 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--crm-text);
    white-space: nowrap;
    width: 100%;
    background: transparent;
    text-align: left;
    cursor: pointer;
    text-decoration: none;
}
.crm-action-menu .crm-action-item:hover,
.crm-action-menu .crm-action-item:focus {
    background: #f4f6f9;
    color: var(--crm-text);
}
.crm-action-menu .crm-action-item.is-danger,
.crm-action-menu .crm-action-item.is-danger:hover,
.crm-action-menu .crm-action-item.is-danger:focus {
    color: #c24141;
    background: #fff5f5;
}
.crm-action-icon {
    width: 16px;
    text-align: center;
    font-size: 13px;
}
.crm-action-icon.is-view { color: #5b6b8c; }
.crm-action-icon.is-edit { color: #e67e22; }
.crm-action-icon.is-delete { color: #c24141; }
.crm-action-menu .crm-action-divider {
    height: 0;
    margin: 4px 6px;
    border: 0;
    border-top: 1px solid var(--crm-line-soft);
}
.crm-empty {
    text-align: center;
    color: var(--crm-muted);
    padding: 28px !important;
}

.crm-table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    color: var(--crm-muted);
    font-size: 13px;
}
.crm-footer-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.crm-per-page {
    display: inline-flex;
    align-items: center;
    margin: 0;
}
.crm-per-page-select {
    height: 30px;
    min-width: 118px;
    padding: 0 30px 0 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background-color: #fff;
    background-image: var(--crm-select-chevron);
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 12px;
    color: var(--crm-text);
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    box-shadow: 0 1px 2px rgba(31, 42, 68, 0.04);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.crm-per-page-select::-ms-expand { display: none; }
.crm-per-page-select:hover {
    border-color: #cfd8e6;
    background-color: #fbfcfe;
}
.crm-per-page-select:focus {
    outline: none;
    border-color: rgba(243, 146, 33, 0.65);
    box-shadow: 0 0 0 3px rgba(243, 146, 33, 0.14);
}
.crm-pagination .pagination {
    margin: 0;
    gap: 4px;
    align-items: center;
}
.crm-pagination .page-item {
    margin: 0;
}
.crm-pagination .page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    margin: 0;
    border: 1px solid var(--crm-border);
    border-radius: 6px !important;
    background: #fff;
    color: #62708b;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
}
.crm-pagination .page-link:hover {
    background: #f4f6f9;
    border-color: #d5dbe8;
    color: var(--crm-text);
}
.crm-pagination .page-link:focus {
    box-shadow: none;
}
.crm-pagination .page-item.active .page-link,
.crm-pagination .page-item.active .page-link:hover {
    background: var(--crm-orange);
    border-color: var(--crm-orange);
    color: #fff;
}
.crm-pagination .page-item.disabled .page-link,
.crm-pagination .page-item.disabled .page-link:hover {
    background: #f7f8fb;
    border-color: var(--crm-border);
    color: #a0a8b8;
    opacity: 1;
}
.crm-form-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
}
.crm-form-stack > .crm-card {
    margin-bottom: 0;
}

/*
 * Lưới field form chuẩn (docs/04-ui-guidelines.md):
 * - Modal / inline: .crm-fields = 2 cột (mặc định)
 * - Form trang (.crm-form-section): 4 → 2 → 1 theo màn hình
 * - .crm-fields-4 = tường minh cùng lưới 4 cột (Hợp đồng…)
 * - Span: .crm-field-span-2 / .crm-field-span-3 / .crm-field-full
 */
.crm-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 16px;
}
.crm-fields-single {
    grid-template-columns: 1fr;
}
.crm-fields-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Form trang: 4 cột (≥1200px) */
.crm-form-section .crm-fields,
.crm-fields-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.crm-field-span-2 { grid-column: span 2; }
.crm-fields .crm-field-full,
.crm-form-section .crm-field-full,
.crm-fields-4 > .crm-field-full { grid-column: 1 / -1; }

@media (max-width: 1199.98px) {
    .crm-form-section .crm-fields,
    .crm-fields-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 767.98px) {
    .crm-fields,
    .crm-fields-2,
    .crm-form-section .crm-fields,
    .crm-fields-4 {
        grid-template-columns: 1fr;
    }
    .crm-field-span-2,.crm-fields .crm-field-full,.crm-form-section .crm-field-full,.crm-fields-4 > .crm-field-full { grid-column: auto; }
}

/* HR-02 thẻ 6 — toggle cấu hình nhân sự */
.crm-toggle-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.crm-toggle {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    cursor: pointer;
    font-weight: 500;
    color: var(--crm-text);
    position: relative;
}
.crm-toggle input[type="checkbox"] {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}
.crm-toggle-switch {
    flex: 0 0 auto;
    width: 34px;
    height: 20px;
    margin-top: 1px;
    border-radius: 999px;
    background: #d5dbe8;
    position: relative;
    transition: background-color .15s ease;
}
.crm-toggle-switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(31, 42, 68, 0.2);
    transition: transform .15s ease;
}
.crm-toggle input[type="checkbox"]:checked + .crm-toggle-switch {
    background: var(--crm-orange);
}
.crm-toggle input[type="checkbox"]:checked + .crm-toggle-switch::after {
    transform: translateX(14px);
}
.crm-toggle input[type="checkbox"]:focus-visible + .crm-toggle-switch {
    box-shadow: 0 0 0 3px rgba(243, 146, 33, 0.2);
}
.crm-toggle-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    padding-top: 1px;
}
.crm-toggle-text strong {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
}
.crm-toggle-text small {
    font-size: 12px;
    color: var(--crm-muted);
    font-weight: 500;
    line-height: 1.3;
}
.crm-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #4c5670;
}
.crm-field label .req { color: #e14b4b; }
.crm-field input,
.crm-field select,
.crm-field textarea {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 12px;
    background: #fff;
    color: var(--crm-text);
    box-shadow: 0 1px 2px rgba(31, 42, 68, 0.03);
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.crm-field input[data-crm-money-input] {
    font-variant-numeric: tabular-nums;
}
.crm-field select {
    height: 42px;
    padding: 0 36px 0 12px;
    background-color: #fff;
    background-image: var(--crm-select-chevron);
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
    font-weight: 500;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
}
.crm-field select::-ms-expand { display: none; }
.crm-field select:hover,
.crm-field input:hover,
.crm-field textarea:hover {
    border-color: #cfd8e6;
}
.crm-field select:focus,
.crm-field input:focus,
.crm-field textarea:focus {
    outline: none;
    border-color: rgba(243, 146, 33, 0.65);
    box-shadow: 0 0 0 3px rgba(243, 146, 33, 0.14);
}
.crm-field textarea { min-height: 120px; resize: vertical; }

/* Modal form — input/select/trigger cùng chiều cao (tránh select 42px vs input lệch) */
.crm-modal-form .crm-fields + .crm-fields,
.crm-modal-form .crm-fields-single + .crm-fields,
.crm-modal-form .crm-fields + .crm-line-item-amount,
.crm-modal-form .crm-line-item-amount + .crm-fields,
.crm-modal-form .crm-fields + .crm-checkline,
.crm-modal-form .crm-fields + .crm-field {
    margin-top: 14px;
}
.crm-modal-form .crm-field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.crm-modal-form .crm-field select {
    height: 42px;
    min-height: 42px;
    padding: 0 12px;
    font-size: 14px;
    line-height: 1.25;
    border-radius: 10px;
    box-sizing: border-box;
}
.crm-modal-form .crm-field select {
    padding-right: 36px;
    background-position: right 12px center;
    background-size: 14px;
}
.crm-modal-form .crm-field .crm-select-trigger {
    height: 42px;
    min-height: 42px;
    padding: 0 12px;
    font-size: 14px;
    border-radius: 10px;
    box-sizing: border-box;
}
.crm-modal-form .crm-field .crm-help {
    margin-top: 6px;
    font-size: 12px;
}
.crm-modal-form .crm-field .crm-error {
    display: block;
    margin-top: 6px;
}

.crm-field .is-readonly {
    background: #f5f7fa;
    color: #6b758c;
}
.crm-help { color: var(--crm-muted); font-size: 12px; margin-top: 6px; }
.crm-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}
.badge-soft-warning { background: #fff1dc; color: #c47a12; }
.badge-soft-success { background: #e7f8ef; color: #1d9a5b; }
.badge-soft-muted { background: #eef1f5; color: #6b758c; }
.badge-soft-primary { background: #edf2ff; color: #4565d9; }
.badge-soft-info { background: #e9f7fb; color: #2f8ca8; }
.badge-soft-danger { background: #fdecec; color: #d04a4a; }

.crm-tabs {
    display: flex;
    gap: 22px;
    border-bottom: 1px solid var(--crm-border);
    margin-bottom: 18px;
    overflow-x: auto;
}
.crm-tabs a {
    padding: 12px 2px;
    color: #6b758c;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
}
.crm-tabs a.active {
    color: var(--crm-orange);
    border-bottom-color: var(--crm-orange);
}
.crm-stat-card {
    background: #fff;
    border: 1px solid var(--crm-border);
    border-radius: 12px;
    padding: 14px 16px;
    min-width: 0;
}
.crm-stat-card span,
.crm-stat-card small {
    display: block;
    color: var(--crm-muted);
    font-size: 12px;
    line-height: 1.35;
}
.crm-stat-card strong {
    display: block;
    margin-top: 4px;
    font-size: 16px;
    font-weight: 800;
    line-height: 1.25;
}
.crm-stat-card small {
    margin-top: 4px;
}
.crm-import-result {
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius);
    padding: 12px 14px;
    margin-bottom: 14px;
    background: #fff;
    white-space: pre-wrap;
}
.crm-import-result.is-ok { border-color: #b7e4c7; background: #f3fbf6; }
.crm-import-result.is-warn { border-color: #f0c089; background: #fff8f0; }
.crm-import-result-title {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-weight: 700;
    font-size: 14px;
    white-space: normal;
}
.crm-import-errors {
    margin: 10px 0 0;
    padding-left: 18px;
    color: #5b6680;
    font-size: 13px;
}
.crm-import-modal .modal-header,
.crm-import-modal .modal-footer {
    border-color: var(--crm-line-soft);
}
.crm-import-modal .modal-title { font-weight: 800; font-size: 16px; }
.crm-import-modal .modal-body { padding: 18px 20px; }
.crm-import-steps { display: grid; gap: 16px; }
.crm-import-step {
    display: grid;
    grid-template-columns: 32px 1fr;
    gap: 12px;
    align-items: start;
}
.crm-import-step-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--crm-navy);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 13px;
}
.crm-import-dropzone {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px dashed #f0c089;
    background: #fff8f0;
    border-radius: 10px;
    padding: 14px 16px;
    cursor: pointer;
    color: #9a6a1f;
    font-weight: 600;
}
.crm-import-dropzone:hover,
.crm-import-dropzone.is-dragover {
    border-color: var(--crm-orange);
    background: #fff3e4;
}
.crm-import-progress { margin-top: 16px; }
.crm-import-progress .progress {
    height: 22px;
    border-radius: 8px;
    background: #eef1f6;
}
.crm-import-progress .progress-bar {
    background: var(--crm-orange);
    font-size: 12px;
    font-weight: 700;
}
.crm-import-progress .progress-bar.is-waiting {
    background: linear-gradient(90deg, #e8891a 0%, var(--crm-orange) 50%, #e8891a 100%);
    background-size: 200% 100%;
}
.crm-import-status {
    font-size: 13px;
    font-weight: 600;
    color: var(--crm-text);
    line-height: 1.4;
}
.modal[data-crm-import-busy="1"] [data-crm-import-dismiss].is-disabled {
    opacity: .45;
    pointer-events: none;
}

@media (max-width: 991.98px) {
    .crm-page-header { align-items: flex-start; flex-direction: column; }
}

/* Turbo Drive progress */
.turbo-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    z-index: 2100;
    background: var(--crm-orange);
    box-shadow: 0 0 8px rgba(243, 146, 33, 0.45);
}

/* ===== Tab panel hồ sơ chi tiết (P2/P3) ===== */
.crm-tab-panel { display: none; }
.crm-tab-panel.active { display: block; }
.crm-tab-panel > .crm-card + .crm-card { margin-top: 18px; }
.crm-chip {
    display: inline-flex;
    align-items: center;
    padding: 5px 14px;
    border-radius: 999px;
    border: 1px solid var(--crm-border);
    background: #fff;
    color: #6b758c;
    font-size: 12px;
    font-weight: 600;
}
.crm-chip.active {
    background: var(--crm-orange);
    border-color: var(--crm-orange);
    color: #fff;
}

.crm-btn-sm {
    height: 32px;
    padding: 0 12px;
    font-size: 12px;
}

/* Modal cắt ảnh vuông 1×1 */
.crm-crop-dialog {
    max-width: 560px;
    width: calc(100% - 24px);
}
.crm-crop {
    border: 1px solid var(--crm-border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 12px 36px rgba(31, 42, 68, 0.14);
}
.crm-crop-header {
    padding: 16px 18px 8px;
}
.crm-crop-title {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
    color: var(--crm-text);
}
.crm-crop-help {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--crm-muted);
    font-weight: 500;
}
.crm-crop-body {
    padding: 8px 18px 12px;
}
.crm-crop-stage {
    position: relative;
    width: 100%;
    height: min(420px, 58vh);
    background: #1a2238;
    border-radius: 10px;
    overflow: hidden;
    user-select: none;
    touch-action: none;
}
.crm-crop-stage img {
    position: absolute;
    left: 0;
    top: 0;
    max-width: none;
    display: block;
    pointer-events: none;
    transform-origin: 0 0;
}
.crm-crop-shade {
    display: none;
}
.crm-crop-box {
    position: absolute;
    box-sizing: border-box;
    border: 2px solid #fff;
    box-shadow: 0 0 0 9999px rgba(10, 14, 28, 0.55);
    cursor: move;
    z-index: 2;
}
.crm-crop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #fff;
    border: 2px solid var(--crm-orange);
    border-radius: 2px;
    z-index: 3;
}
.crm-crop-handle.is-nw { left: -6px; top: -6px; cursor: nwse-resize; }
.crm-crop-handle.is-ne { right: -6px; top: -6px; cursor: nesw-resize; }
.crm-crop-handle.is-sw { left: -6px; bottom: -6px; cursor: nesw-resize; }
.crm-crop-handle.is-se { right: -6px; bottom: -6px; cursor: nwse-resize; }
.crm-crop-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 18px 16px;
    flex-wrap: wrap;
}
.crm-crop-zoom,
.crm-crop-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Footer lịch flatpickr: Hôm nay / Xóa */
.crm-fp-footer {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 10px;
    border-top: 1px solid var(--crm-border);
    background: #fff;
}
.crm-fp-btn {
    border: 0;
    background: none;
    color: var(--crm-orange);
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 6px;
}
.crm-fp-btn:hover { background: #fff4e8; }
.crm-fp-btn.is-muted { color: #6b758c; }
.crm-fp-btn.is-muted:hover { background: #eef1f5; }

/* ============ Nhân sự — list / form / cây tổ chức ============ */
.crm-page-subtitle { color: #6b758c; font-size: 13px; margin: 0; }
.crm-page-subline {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 10px; margin-top: 4px;
}
.crm-form-required-counter { margin: 0; font-size: 13px; }
.crm-page-tabs {
    display: flex; gap: 22px; margin: 14px 0 16px;
    border-bottom: 1px solid #e4e8ef;
}
.crm-page-tab {
    display: inline-block; padding: 8px 2px 10px; font-weight: 600; font-size: 13.5px;
    color: #6b758c; text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.crm-page-tab:hover { color: #38497b; }
.crm-page-tab.is-active { color: #38497b; border-bottom-color: #f29220; }
.crm-page-tab.is-disabled { color: #b3bac9; cursor: not-allowed; }
.crm-filter-inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.crm-name-cell { display: inline-flex; align-items: center; gap: 10px; }
.crm-name-link { color: #f29220; font-weight: 600; text-decoration: none; }
.crm-name-link.as-button {
    background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-align: left;
}
.crm-name-link:hover { text-decoration: underline; color: #d97f12; }
.crm-avatar-initials {
    width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; object-fit: cover;
    background: #38497b; color: #fff; font-size: 11px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
}
.crm-employee-ticket {
    position: fixed;
    z-index: 2200;
    width: min(460px, calc(100vw - 16px));
    border: 1px solid #dfe5ef;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 14px 34px rgba(31, 42, 68, 0.18);
    padding: 16px;
}
.crm-employee-ticket-close {
    position: absolute;
    top: 10px;
    right: 10px;
    border: 0;
    background: transparent;
    color: #9aa3b5;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    cursor: pointer;
}
.crm-employee-ticket-close:hover { background: #f2f5f9; color: #62708b; }
.crm-employee-ticket-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.crm-employee-ticket-avatar {
    width: 54px; height: 54px; border-radius: 50%;
    background: #1f4772; color: #fff; font-size: 28px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.crm-employee-ticket-meta { min-width: 0; }
.crm-employee-ticket-name {
    margin: 0 0 2px;
    color: #1e2948;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.15;
}
.crm-employee-ticket-email { color: #2a63d8; font-size: 14px; text-decoration: none; }
.crm-employee-ticket-email:hover { text-decoration: underline; }
.crm-employee-ticket-sub { margin: 3px 0 0; color: #6b758c; font-size: 13px; }
.crm-employee-ticket-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.crm-employee-ticket-actions form { margin: 0; }
.crm-employee-ticket-btn {
    height: 44px;
    border: 1px solid #dfe5ef;
    border-radius: 12px;
    background: #fff;
    color: #38497b;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}
.crm-employee-ticket-btn:disabled { opacity: .65; cursor: not-allowed; }
.crm-employee-ticket-btn.is-danger {
    background: #e32727;
    border-color: #e32727;
    color: #fff;
}
.crm-toggle-solo { margin: 0; display: inline-flex; }
.crm-table-footer-right { display: flex; align-items: center; gap: 16px; }

/* Form trang — section đánh số (NS/KH/HD…) */
.crm-form-section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.crm-form-section-head .crm-card-title,
.crm-form-section-head h2 {
    margin: 0 0 2px;
    padding: 0;
    border-bottom: none;
    font-size: 15px;
    font-weight: 800;
    line-height: 1.3;
    color: var(--crm-text);
}
.crm-form-section-head p,
.crm-form-section-head .crm-muted {
    margin: 0;
    font-size: 13px;
    color: #6b758c;
}
.crm-form-section-no {
    width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
    background: #fdeeda; color: #f29220; font-weight: 700; font-size: 13px;
    display: inline-flex; align-items: center; justify-content: center;
}
.crm-employees-personal { display: flex; gap: 22px; align-items: flex-start; }
.crm-employees-personal-fields { flex: 1; min-width: 0; }

/* Avatar upload — khung nét đứt vuông 1×1 */
.crm-avatar-upload { flex: 0 0 124px; width: 124px; }
.crm-avatar-upload-box {
    display: block; width: 124px; height: 124px; margin: 0; cursor: pointer;
    border: 1.5px dashed #cfd6e4; border-radius: 10px;
    background: #f8fafc; overflow: hidden; position: relative;
}
.crm-avatar-upload-box:hover { border-color: #f29220; background: #fffaf3; }
.crm-avatar-upload-preview {
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%;
}
.crm-avatar-upload-preview img {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.crm-avatar-upload-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 6px; padding: 8px; text-align: center;
}
/* Silhouette tròn — icon user */
.crm-avatar-upload-silhouette {
    width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
    background: #d8dee9; color: #f8fafc;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 18px;
}
.crm-avatar-upload-link {
    color: #f29220; font-size: 13px; font-weight: 600; line-height: 1.2;
}
.crm-avatar-upload-hint {
    color: #9aa3b5; font-size: 11px; line-height: 1.2;
}
.crm-avatar-upload .crm-error { margin-top: 6px; font-size: 12px; }

@media (max-width: 767px) {
    .crm-employees-personal { flex-direction: column; }
}

/* NS-M1 modal nghỉ việc */
.crm-resign-dialog { max-width: 620px; }
.crm-resign-section { font-weight: 700; font-size: 13px; margin: 16px 0 8px; color: #1e2948; }
.crm-resign-checklist { display: flex; flex-direction: column; }
.crm-resign-check {
    display: flex; gap: 10px; align-items: flex-start; padding: 10px 2px;
    border-bottom: 1px solid #eef1f5; margin: 0; cursor: pointer;
}
.crm-resign-check:last-child { border-bottom: 0; }
.crm-resign-check input { margin-top: 3px; accent-color: #f29220; }
.crm-resign-check-text { display: flex; flex-direction: column; gap: 2px; }
.crm-resign-check-text strong { font-size: 13px; color: #1e2948; }
.crm-resign-check-text small { color: #6b758c; }
.crm-resign-check.is-disabled { opacity: .55; cursor: not-allowed; }
.crm-resign-banner {
    margin-top: 14px; padding: 10px 12px; border-left: 3px solid #f2b04b;
    background: #fdf6e8; color: #6b5b2a; font-size: 12.5px; border-radius: 6px;
}

/* NS-04 cây cơ cấu tổ chức */
.crm-tree-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; flex-wrap: wrap; margin-bottom: 14px;
}
.crm-tree-toolbar-left { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.crm-tree-toolbar .crm-search-wrap { width: 320px; max-width: 100%; }
.crm-tree-switch {
    display: inline-flex; align-items: center; gap: 8px; margin: 0;
    font-size: 13px; color: #4a5468; cursor: pointer;
}
.crm-tree-card { padding: 10px 6px; }
.crm-tree, .crm-tree-children { list-style: none; margin: 0; padding: 0; }
.crm-tree-children { padding-left: 26px; }
.crm-tree-item.is-collapsed > .crm-tree-children { display: none; }
.crm-tree-item.is-hidden { display: none; }
.crm-tree-row {
    display: flex; align-items: center; gap: 10px; min-height: 45px;
    padding: 0 12px; border-radius: 8px;
}
.crm-tree-row:hover { background: #f7f9fc; }
.crm-tree-expander {
    width: 16px; height: 16px; flex-shrink: 0; padding: 0; line-height: 1;
    border: 1px solid #cbd5e1; border-radius: 4px; background: #f1f5f9;
    color: #64748b; font-size: 12px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
}
.crm-tree-expander.is-leaf { border-color: transparent; background: transparent; }
.crm-tree-name { font-size: 13.5px; color: #1e2948; font-weight: 600; }
.crm-tree-name.is-root { font-weight: 700; }
.crm-tree-item.is-inactive > .crm-tree-row .crm-tree-name { color: #9aa3b5; font-weight: 500; }
.crm-tree-code {
    font-size: 11.5px; color: #6b758c; background: #eef1f5;
    border-radius: 4px; padding: 1px 6px; font-weight: 600;
}
.crm-tree-manager { font-size: 12px; color: #6b758c; }
.crm-tree-manager i { margin-right: 4px; color: #a9b2c4; }
.crm-tree-count { margin-left: auto; font-size: 12.5px; color: #64748b; white-space: nowrap; }
.crm-tree-menu-slot { width: 34px; flex-shrink: 0; display: flex; justify-content: flex-end; }
.crm-tree-empty { text-align: center; color: #6b758c; font-size: 13px; padding: 24px 0 12px; margin: 0; }
.crm-tree-hidden-note { color: #8a93a6; font-size: 12.5px; padding: 10px 12px 4px; margin: 0; }
/* NS-05 / NS-M3 vai trò */
.crm-role-dialog { max-width: 680px; }
.crm-role-name { font-weight: 600; color: #1e2948; margin-right: 6px; }
.crm-role-edit {
    background: none; border: 0; padding: 0; font: inherit; cursor: pointer;
}
.crm-role-matrix th, .crm-role-matrix td { padding: 7px 10px; vertical-align: middle; }
.crm-role-matrix input[type="checkbox"] {
    accent-color: #f29220; width: 16px; height: 16px;
    margin: 0; vertical-align: middle; flex-shrink: 0;
}
.crm-role-matrix tr.is-hidden { display: none; }
[data-crm-role-list] tr.is-hidden { display: none; }
.crm-role-group > td { background: #f7f9fc; }
.crm-role-group-head {
    display: inline-flex; align-items: center; gap: 8px;
    min-height: 22px;
}
.crm-role-group-toggle {
    width: 16px; height: 16px; padding: 0; margin: 0; line-height: 1;
    border: 1px solid #cbd5e1; border-radius: 4px; background: #f1f5f9;
    color: #64748b; font-size: 12px; font-weight: 700; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
}
.crm-role-group-label {
    display: inline-flex; align-items: center; gap: 8px; margin: 0;
    font-weight: 700; font-size: 13px; line-height: 1.2; color: #1e2948; cursor: pointer;
}
.crm-role-subject > td.text-center {
    text-align: center; vertical-align: middle;
}
.crm-role-subject-name { padding-left: 34px !important; color: #4a5468; }
.crm-role-na { color: #c3c9d6; display: inline-block; line-height: 16px; vertical-align: middle; }
.crm-role-extra {
    display: flex; align-items: center; gap: 6px; margin: 0 0 3px;
    font-size: 12.5px; line-height: 1.2; color: #4a5468; cursor: pointer; white-space: nowrap;
}
.crm-role-extra:last-child { margin-bottom: 0; }
.crm-role-extra input { accent-color: #f29220; }
/* Toggle không có checkbox (nút submit form) — trạng thái bật đặt bằng class */
.crm-toggle-button { background: none; border: 0; padding: 0; cursor: pointer; }
.crm-toggle-switch.is-on { background: var(--crm-orange); }
.crm-toggle-switch.is-on::after { transform: translateX(14px); }

/* Ô mật khẩu có nút con mắt */
.crm-password-wrap { position: relative; display: block; }
.crm-password-wrap > input { width: 100%; padding-right: 38px; }
.crm-password-eye {
    position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
    width: 28px; height: 28px; padding: 0; border: 0; background: transparent;
    color: #8a93a6; border-radius: 6px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.crm-password-eye:hover { color: #38497b; background: #eef1f5; }

.crm-dept-dialog { max-width: 560px; }
.crm-dept-dialog input.is-locked { background: #f4f6fa; color: #6b758c; }

/* ============ Danh sách chung — bộ lọc, cột, bảng ============ */
.is-active-filter { border-color: #f29220 !important; color: #f29220 !important; }

.crm-filter-panel {
    margin-top: 0;
    border-top: 1px solid #eef1f5;
    padding: 16px;
}
.crm-filter-panel.is-hidden { display: none; }
.crm-filter-title { font-weight: 700; font-size: 13px; color: #1e2948; margin: 0 0 12px; display: flex; align-items: center; }
.crm-filter-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px 16px;
    align-items: start;
}
.crm-filter-footer {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin-top: 14px; padding-top: 12px; border-top: 1px solid #eef1f5; flex-wrap: wrap;
}
.crm-filter-actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 1199.98px) {
    .crm-filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 991.98px) {
    .crm-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 575.98px) {
    .crm-filter-grid { grid-template-columns: 1fr; }
}

.crm-list-table-card,
.crm-side-panel {
    padding: 0;
    overflow: hidden;
}
.crm-list-table-card .crm-table thead th {
    height: 42px;
    padding-top: 0;
    padding-bottom: 0;
    vertical-align: middle;
    box-sizing: border-box;
}
.crm-list-table-card .crm-table-footer {
    margin: 0;
    padding: 12px 14px;
    border-top: 1px solid var(--crm-line-soft);
}
.crm-list-table [data-list-col].is-hidden { display: none; }
.crm-list-table tr[data-list-row] { cursor: pointer; }
.crm-list-table tr[data-list-row].is-selected > td { background: #fdf3e6; }
.crm-columns-menu { min-width: 190px; padding: 6px 8px; }
.crm-column-item {
    display: flex; align-items: center; gap: 8px; margin: 0; padding: 6px 4px;
    font-size: 13px; color: #4a5468; cursor: pointer;
}
.crm-column-item input { accent-color: #f29220; }
.crm-column-item.is-locked {
    opacity: 0.72;
    cursor: not-allowed;
}
.crm-column-item.is-locked input { cursor: not-allowed; }

/* Xuất Excel — spinner trên nút đang xử lý */
.crm-btn.is-exporting,
.crm-action-item.is-exporting {
    pointer-events: none;
    opacity: 0.85;
}

/* Chip trạng thái chấm màu (danh sách + hồ sơ) */
.crm-status { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; }
.crm-status-dot { width: 8px; height: 8px; border-radius: 50%; }
.crm-status.is-1 { color: #16833f; }
.crm-status.is-1 .crm-status-dot { background: #16a34a; }
.crm-status.is-2 { color: #b45309; }
.crm-status.is-2 .crm-status-dot { background: #f29220; }
.crm-status.is-3 { color: #b91c1c; }
.crm-status.is-3 .crm-status-dot { background: #dc2626; }
.crm-status.is-4 { color: #6b758c; }
.crm-status.is-4 .crm-status-dot { background: #94a3b8; }

/* ============ Khách hàng v4 — layout KH-01 (panel phải) ============ */
.crm-list-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.crm-side-panel { position: sticky; top: 80px; }
.crm-side-panel-tabs {
    display: flex;
    align-items: stretch;
    gap: 18px;
    margin: 0;
    min-height: 42px;
    padding: 0 14px;
    border-bottom: 1px solid var(--crm-border);
    background: transparent;
}
.crm-side-panel-tabs .crm-page-tab {
    display: inline-flex;
    align-items: center;
    height: 42px;
    margin: 0;
    padding: 0 2px;
    border-top: 0;
    border-left: 0;
    border-right: 0;
    border-bottom-width: 2px;
    margin-bottom: -1px;
    background: none;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.25;
    cursor: pointer;
}
.crm-side-panel-name {
    font-weight: 700;
    font-size: 13.5px;
    color: #1e2948;
    margin: 0;
    padding: 12px 14px 0;
}
.crm-side-panel-body { padding: 10px 14px 14px; }
.crm-side-panel-hint { color: #8a93a6; font-size: 12.5px; text-align: center; padding: 26px 8px; margin: 0; }
.crm-side-panel-item { padding: 8px 0; border-bottom: 1px solid #eef1f5; }
.crm-side-panel-item:last-child { border-bottom: 0; }
.crm-side-panel-item strong { display: block; font-size: 13px; color: #1e2948; font-weight: 600; }
.crm-side-panel-item small { color: #8a93a6; font-size: 12px; }

/* Chip liên hệ phụ trong form KH-03 */
.crm-chip-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.crm-chip {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    background: #f7f9fc; border: 1px solid #e4e8ef; border-radius: 8px; padding: 8px 12px;
}
.crm-chip-text { font-size: 13px; color: #1e2948; }
.crm-chip-remove {
    background: none; border: 0; color: #8a93a6; cursor: pointer; font-size: 12px; padding: 2px 6px;
}
.crm-chip-remove:hover { color: #d64545; }

/* Modal xoá KH-M3 */
.crm-alert-warning {
    padding: 10px 12px; border-left: 3px solid #f2b04b; background: #fdf6e8;
    color: #6b5b2a; font-size: 12.5px; border-radius: 6px; margin: 0 0 12px;
}

@media (max-width: 1199px) {
    .crm-list-layout { grid-template-columns: 1fr; }
    .crm-side-panel { position: static; }
}

/* ============================================================
   Hồ sơ 360° — layout rail/main/stats/block (NV · KH · HĐ)
   ============================================================ */
.crm-record-header { align-items: flex-start; }
.crm-record-heading,
.crm-record-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.crm-record-heading h1,
.crm-record-title h1 { margin: 0; }

.crm-record-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.crm-record-rail { display: flex; flex-direction: column; gap: 16px; }
.crm-record-card { padding: 18px 20px; }
.crm-record-card.is-identity { text-align: center; }

.crm-record-avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 64px; height: 64px; border-radius: 50%;
    background: #38497b; color: #fff; font-size: 20px; font-weight: 700;
    margin-bottom: 10px;
}
img.crm-record-avatar { object-fit: cover; display: block; margin-left: auto; margin-right: auto; }
.crm-record-avatar.is-initials { font-size: 22px; }

.crm-record-name { font-size: 16px; font-weight: 700; color: #232a38; margin: 0 0 4px; }
.crm-record-sub,
.crm-record-role { color: #6b758c; font-size: 12.5px; margin: 0 0 12px; }

.crm-record-quick { display: flex; gap: 8px; justify-content: center; }
.crm-record-quick-btn {
    flex: 1; text-align: center; padding: 6px 4px; border: 1px solid #dfe3ec; border-radius: 8px;
    background: #f7f8fb; color: #38497b; font-size: 12.5px; font-weight: 600;
    text-decoration: none; cursor: pointer;
}
.crm-record-quick-btn:hover { background: #eef1f8; color: #38497b; }
.crm-record-quick-btn.is-disabled { color: #b3bac9; cursor: not-allowed; pointer-events: none; opacity: .72; }

.crm-record-section,
.crm-record-rail-title {
    font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    color: #64748b; margin: 0 0 12px;
}

.crm-record-contact { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.crm-record-contact-avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 50%; flex: 0 0 auto;
    background: #eef1f8; color: #38497b; font-size: 12px; font-weight: 700;
}
.crm-record-contact-avatar.is-small { width: 28px; height: 28px; font-size: 11px; margin-right: 8px; }
.crm-record-contact-meta { display: flex; flex-direction: column; min-width: 0; }
.crm-record-contact-meta strong { font-size: 13px; color: #232a38; }
.crm-record-contact-meta small { color: #6b758c; font-size: 12px; }

.crm-record-link { color: #f29220; font-size: 12.5px; font-weight: 600; text-decoration: none; cursor: pointer; }
.crm-record-link:hover { color: #d97f12; }
.crm-record-link.is-disabled { color: #b3bac9; cursor: not-allowed; }
.crm-record-link.as-button { background: none; border: 0; padding: 0; font: inherit; font-size: 12.5px; font-weight: 600; }

.crm-record-list { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 0; }
.crm-record-list dt { color: #8a93a8; font-size: 12px; font-weight: 500; }
.crm-record-list dd { margin: 2px 0 0; color: #232a38; font-size: 13px; word-break: break-word; }

.crm-record-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.crm-record-main > .crm-page-tabs { margin: 0; }
.crm-record-tabs a.crm-page-tab { text-decoration: none; }

.crm-record-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }

.crm-record-block { padding: 18px 20px; }
.crm-record-block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.crm-record-block-head h3 { font-size: 14.5px; font-weight: 700; color: #232a38; margin: 0; }
.crm-record-placeholder { color: #8a93a8; font-size: 13px; margin: 4px 0 2px; }
.crm-record-placeholder.is-box {
    margin: 0; padding: 22px; text-align: center;
    background: #f8fafc; border: 1px dashed #dbe2ec; border-radius: 10px;
}

/* Timeline gọn (hồ sơ NV) */
.crm-record-activity {
    display: flex; align-items: center; gap: 12px; min-height: 40px;
    border-bottom: 1px solid #eef1f5; font-size: 13px; color: #4a5468;
}
.crm-record-activity:last-child { border-bottom: 0; }
.crm-record-activity-date { width: 96px; flex-shrink: 0; color: #8a93a6; font-size: 12.5px; }
.crm-record-activity-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: #2563eb;
}
.crm-record-activity-dot.is-type-3 { background: #16a34a; }
.crm-record-activity-dot.is-type-4 { background: #f29220; }

/* Danh sách SP / tiến độ TT (hồ sơ HĐ) */
.crm-record-itemlist { list-style: none; margin: 0; padding: 0; }
.crm-record-itemlist li {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 0; border-bottom: 1px solid #f1f5f9;
}
.crm-record-itemlist li:last-child { border-bottom: 0; }
.crm-record-itemname { flex: 1; min-width: 0; color: #0f172a; }
.crm-record-itemqty { color: #94a3b8; font-size: 12.5px; white-space: nowrap; }
.crm-record-itemlist strong { font-variant-numeric: tabular-nums; white-space: nowrap; }

.crm-record-progress { list-style: none; margin: 0; padding: 0; }
.crm-record-progress-row {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 0; border-bottom: 1px solid #f1f5f9; flex-wrap: wrap;
}
.crm-record-progress-row:last-child { border-bottom: 0; }
.crm-record-progress-main { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 2px; }
.crm-record-progress-main strong { font-size: 13px; color: #0f172a; }
.crm-record-progress-main small { font-size: 11.5px; color: #94a3b8; }
.crm-record-progress-amount { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.crm-record-progress-amount strong { font-variant-numeric: tabular-nums; }
.crm-record-progress-amount small { font-size: 11.5px; color: #64748b; }

.crm-record-total-row td { background: #f8fafc; border-top: 1.5px solid #e2e8f0; }
.crm-record-total-amount { color: #ea580c; font-size: 15px; font-weight: 600; }

.crm-record-debt {
    background: #fff4ea; border-radius: 10px; padding: 14px 16px; display: grid; gap: 8px;
}
.crm-record-debt > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.crm-record-debt span { color: #8a5a12; font-size: 12.5px; }
.crm-record-debt strong { color: #0f172a; font-variant-numeric: tabular-nums; }
.crm-record-debt .is-outstanding { border-top: 1px solid #fadfc4; padding-top: 8px; }
.crm-record-debt .is-outstanding strong { color: #ea580c; font-size: 18px; font-weight: 700; }

.crm-record-banner {
    margin: 0; padding: 11px 14px; border-radius: 8px;
    background: #eff6ff; border-left: 3px solid #3b82f6; color: #1e40af; font-size: 12.5px;
}

.crm-stat-card { display: flex; flex-direction: column; gap: 4px; }
.crm-stat-card.is-pending { background: #fbfcfe; }
.crm-stat-label { font-size: 12px; color: #6b758c; }
.crm-stat-value { font-size: 20px; font-weight: 700; color: #1e2948; }
.crm-stat-value.is-orange { color: #ea580c; }
.crm-stat-value.is-red { color: #dc2626; }
.crm-stat-value.is-green { color: #1d9a5b; }
.crm-stat-note { font-size: 11.5px; color: #8a93a6; }

/* Bảng liên hệ KH-05 */
.crm-record-kv { display: grid; gap: 14px 24px; margin: 0; }
.crm-record-kv.is-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.crm-record-kv.is-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.crm-record-kv > div.is-full { grid-column: 1 / -1; }
.crm-record-kv dt { color: #8a93a8; font-size: 12px; font-weight: 500; }
.crm-record-kv dd { margin: 3px 0 0; color: #232a38; font-size: 13px; word-break: break-word; }
.crm-record-kv dd a { color: #ea580c; text-decoration: none; }
.crm-record-kv dd a:hover { text-decoration: underline; }
.crm-record-status-text { font-weight: 600; }
.crm-record-status-text.is-1 { color: #1d9a5b; }
.crm-record-status-text.is-2 { color: #c47a12; }
.crm-record-status-text.is-3 { color: #d04a4a; }
.crm-record-status-text.is-4 { color: #6b758c; }

/* Bảng liên hệ KH-05 */
.crm-record-contact-table td { vertical-align: middle; }

/* Căn lại cột "Họ tên" theo layout KH-02 (avatar + tên cùng baseline) */
.crm-record-contact-table .crm-record-contact { margin-bottom: 0; }
.crm-record-contact-table .crm-record-contact-avatar.is-small { margin-right: 0; }
.crm-record-contact-name-btn {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: #232a38;
    font-weight: 700;
    font-size: 13px;
    line-height: 1.2;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
}
.crm-record-contact-name-btn:hover { text-decoration: underline; }
.crm-record-contact-name-text {
    color: #232a38;
    font-weight: 700;
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
}

/* Modal KH-M4 */
.crm-record-modal-section { font-size: 13px; font-weight: 700; color: #232a38; margin: 0 0 10px; }
.crm-record-replace-primary { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: #232a38; cursor: pointer; }
.crm-record-replace-primary input { margin-top: 2px; }
.crm-record-modal-footer { display: flex; align-items: center; }
.crm-record-modal-spacer { flex: 1; }
.crm-btn.is-danger { color: #d04a4a; }

@media (max-width: 1199px) {
    .crm-record-layout { grid-template-columns: 1fr; }
    .crm-record-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .crm-record-kv.is-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
    .crm-record-stats { grid-template-columns: 1fr; }
    .crm-record-kv.is-3, .crm-record-kv.is-2 { grid-template-columns: 1fr; }
}

/* ============================================================
   KH v4 đợt 4 — KH-07 Hoạt động + KH-09 Đính kèm (+ KH-M6/M8)
   ============================================================ */
.crm-record-activity-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.crm-record-activity-bar .crm-filter-select { min-width: 180px; }
.crm-record-activity-spacer { flex: 1; }

.crm-record-event {
    display: flex; align-items: flex-start; gap: 14px;
    padding: 13px 0; border-bottom: 1px solid #eef1f5;
}
.crm-record-event:last-of-type { border-bottom: 0; }
.crm-record-event-date { flex: 0 0 84px; color: #6b758c; font-size: 12.5px; padding-top: 2px; }
.crm-record-event-dot {
    flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; background: #b3bac9;
}
.crm-record-event-dot.is-type-1 { background: #4565d9; }  /* Cuộc gọi */
.crm-record-event-dot.is-type-2 { background: #f29220; }  /* Email */
.crm-record-event-dot.is-type-3 { background: #1d9a5b; }  /* Gặp mặt */
.crm-record-event-dot.is-type-4 { background: #6b758c; }  /* Ghi chú */
.crm-record-event-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.crm-record-event-title { font-weight: 600; color: #232a38; font-size: 13.5px; }
.crm-record-event-title.as-button {
    background: none; border: 0; padding: 0; text-align: left; cursor: pointer; font: inherit; font-weight: 600;
}
.crm-record-event-title.as-button:hover { color: #38497b; text-decoration: underline; }
.crm-record-event-meta small { color: #6b758c; font-size: 12.5px; }
.crm-record-event-actor { flex: 0 0 auto; color: #232a38; font-size: 12.5px; padding-top: 2px; }
.crm-record-event-chip { flex: 0 0 auto; }

/* KH-M6: 4 nút loại hoạt động (segmented) */
.crm-record-seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.crm-record-seg-item { position: relative; display: block; cursor: pointer; margin: 0; }
.crm-record-seg-item input { position: absolute; opacity: 0; pointer-events: none; }
.crm-record-seg-item span {
    display: block; text-align: center; padding: 8px 6px; border: 1px solid #dfe3ec; border-radius: 8px;
    font-size: 13px; font-weight: 600; color: #6b758c; background: #fff;
}
.crm-record-seg-item input:checked + span { border-color: #f29220; color: #d97f12; background: #fff6ec; }
.crm-record-seg-item input:focus-visible + span { outline: 2px solid #38497b; outline-offset: 1px; }

/* KH-09: dropzone */
.crm-record-dropzone {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    width: 100%; padding: 26px 16px; cursor: pointer;
    border: 1.5px dashed #c7cedd; border-radius: 12px; background: #fbfcfe;
}
.crm-record-dropzone strong { color: #232a38; font-size: 13.5px; }
.crm-record-dropzone small { color: #8a93a8; font-size: 12.5px; }
.crm-record-dropzone:hover, .crm-record-dropzone.is-dragover { border-color: #f29220; background: #fff6ec; }
.crm-record-dropzone.is-compact { padding: 20px 14px; }
/* Input file ẩn nhưng vẫn focusable — control `hidden` mà invalid bị browser huỷ submit im lặng */
.crm-record-dropzone-wrap { position: relative; }
.crm-record-file-input {
    position: absolute; left: 12px; bottom: 6px;
    width: 1px; height: 1px; padding: 0; margin: 0;
    opacity: 0; border: 0; overflow: hidden;
}

/* KH-M8: dòng tệp đã chọn */
.crm-record-file-row {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    margin-top: 10px; padding: 9px 12px; border: 1px solid #dfe3ec; border-radius: 8px;
    background: #f7f8fb; font-size: 13px; color: #232a38;
}
.crm-record-file-remove { background: none; border: 0; color: #8a93a8; cursor: pointer; font-size: 13px; }
.crm-record-file-remove:hover { color: #d04a4a; }

/* ============================================================
   KH v4 đợt 5 — KH-08 Hỗ trợ + KH-M7 ticket
   ============================================================ */
.crm-record-stats.is-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
/* Media query KHÔNG cộng specificity: .crm-record-stats ở block responsive phía trên
   (0,1,0) thua .is-3 (0,2,0) nên phải override tại chỗ, ĐẶT SAU dòng trên. */
@media (max-width: 1199px) {
    .crm-record-stats.is-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
    .crm-record-stats.is-3 { grid-template-columns: 1fr; }
}
.crm-stat-value.is-green { color: #1d9a5b; }

/* Cảnh báo quá hạn SLA (chốt user: cảnh báo trên UI, chưa gửi thông báo) */
.crm-record-alert {
    display: flex; align-items: center; gap: 9px;
    padding: 11px 14px; border-radius: 10px;
    background: #fdecec; border-left: 3px solid #d04a4a; color: #a83a3a; font-size: 13px;
}

/* Chấm màu mức độ ưu tiên — tái dùng .crm-status-dot */
.crm-priority { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; }
.crm-priority .crm-status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.crm-priority.is-urgent { color: #c0392b; }
.crm-priority.is-high { color: #d04a4a; }
.crm-priority.is-normal { color: #c47a12; }
.crm-priority.is-low { color: #6b758c; }

.crm-record-overdue { margin-left: 8px; }
.crm-code.as-button {
    background: none; border: 0; padding: 0; font: inherit; cursor: pointer;
    color: #38497b; font-weight: 600;
}
.crm-code.as-button:hover { text-decoration: underline; }

/* Banner SLA trong KH-M7 */
.crm-record-sla-banner {
    margin: 0; padding: 11px 14px; border-radius: 8px;
    background: #fff6ec; border-left: 3px solid #f29220; color: #8a5a12; font-size: 12.5px;
}
.crm-record-sla-banner:empty { display: none; }
.crm-record-ticket-resolve { border-top: 1px solid #eef1f5; padding-top: 14px; }

/* ===== Form Hợp đồng + số liệu bảng ===== */
.crm-num { font-variant-numeric: tabular-nums; }
.crm-num.is-muted { color: #64748b; }
.crm-num.is-debt { color: #dc2626; font-weight: 600; }
.crm-num.is-zero { color: #94a3b8; }
.crm-name-link.is-plain { color: inherit; cursor: default; }

.crm-foot-extended { flex-wrap: wrap; align-items: center; gap: 16px; }
.crm-foot-totals { display: flex; gap: 28px; flex-wrap: wrap; }
.crm-foot-total { display: flex; flex-direction: column; gap: 2px; }
.crm-foot-total span { font-size: 11.5px; color: #64748b; }
.crm-foot-total strong { font-size: 14px; color: #0f172a; font-variant-numeric: tabular-nums; }
.crm-foot-total strong.is-green { color: #16a34a; }
.crm-foot-total strong.is-red { color: #dc2626; }

.crm-line-items th { font-size: 11.5px; }
.crm-line-items td { padding-top: 13px; padding-bottom: 13px; }
.crm-line-items .crm-line-items-no { width: 40px; color: #94a3b8; }
.crm-line-items .crm-line-items-unit { width: 110px; color: #475569; }
.crm-line-items .crm-line-items-qty { width: 96px; }
.crm-line-items .crm-line-items-price { width: 140px; }
.crm-line-items .crm-line-items-amount {
    width: 160px; font-weight: 600; color: #0f172a; font-variant-numeric: tabular-nums;
}
.crm-line-items .crm-line-items-remove { width: 40px; text-align: right; }
/* Tên dòng: chữ đen thường như mockup, bấm được để sửa (thêm ngoài mockup) */
.crm-line-item-name {
    border: 0; background: none; padding: 0; text-align: left;
    color: #0f172a; font: inherit; cursor: pointer;
}
.crm-line-item-name:hover { color: #ea580c; text-decoration: underline; }
.crm-line-item-remove {
    border: 0; background: none; padding: 2px 6px; color: #cbd5e1;
    font-size: 15px; line-height: 1; cursor: pointer; border-radius: 6px;
}
.crm-line-item-remove:hover { color: #dc2626; background: #fdeaea; }
.crm-line-items-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding-top: 12px; flex-wrap: wrap;
}
.crm-grand-total { display: flex; align-items: baseline; gap: 12px; }
.crm-grand-total span { color: #64748b; font-size: 13px; }
.crm-grand-total strong { color: #ea580c; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.crm-locked-note {
    margin: 0 0 10px; padding: 9px 12px; border-radius: 8px;
    background: #f8fafc; border: 1px dashed #cbd5e1; color: #64748b; font-size: 12.5px;
}

/* HD-02 khối 4 */
.crm-note-fields { grid-template-columns: 2fr 1fr; }
.crm-note-field input { width: 100%; }
.crm-record-dropzone.is-inline {
    display: flex; align-items: center; justify-content: center; text-align: center;
    min-height: 42px; padding: 10px 12px; border: 1.5px dashed #cbd5e1; border-radius: 8px;
    background: #f8fafc; color: #64748b; font-size: 12.5px; cursor: pointer;
}
.crm-record-dropzone.is-inline:hover { border-color: #f29220; color: #b45309; background: #fff9f2; }
.crm-record-dropzone.is-inline input[type="file"] {
    position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden;
}

/* HD-M2 — dải thành tiền cam */
.crm-line-item-amount {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px; border-radius: 8px; background: #fff4ea;
}
.crm-line-item-amount span { color: #8a5a12; font-size: 12.5px; }
.crm-line-item-amount strong { color: #ea580c; font-size: 16px; font-variant-numeric: tabular-nums; }
.crm-checkline { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #334155; }
.crm-checkline input { accent-color: #f29220; }

@media (max-width: 991px) {
    .crm-note-fields { grid-template-columns: 1fr; }
    .crm-foot-totals { gap: 16px; }
}

/* ===== NS-03 biểu đồ doanh số 6 kỳ (đợt 4) — cột CSS thuần, không kéo thư viện ===== */
.crm-bar-chart {
    display: flex; align-items: flex-end; gap: 14px;
    height: 168px; padding: 8px 4px 0;
}
.crm-bar-col {
    flex: 1 1 0; display: flex; flex-direction: column; align-items: center;
    justify-content: flex-end; height: 100%; gap: 6px; min-width: 0;
}
.crm-bar-value { font-size: 11.5px; color: #6b758c; white-space: nowrap; }
.crm-bar {
    width: 100%; max-width: 46px; border-radius: 6px 6px 0 0;
    background: linear-gradient(180deg, #f7a94a 0%, #f29221 100%);
    transition: height .2s ease;
}
.crm-bar.is-negative { background: linear-gradient(180deg, #e98b8b 0%, #d04a4a 100%); }
.crm-bar-label { font-size: 11.5px; color: #6b758c; white-space: nowrap; }
