: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-sidebar-width: 260px;
    --crm-sidebar-collapsed-width: 64px;
    --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;
    background: var(--crm-bg);
    overflow: hidden;
}
.crm-sidebar {
    width: var(--crm-sidebar-width);
    background: var(--crm-navy);
    color: #d5dbeb;
    height: 100vh;
    max-height: 100vh;
    padding: 0 0 16px;
    position: relative;
    flex-shrink: 0;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    z-index: 1040;
}
.crm-sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 67px;
    padding: 0;
    margin: 0;
}
.crm-sidebar-brand .crm-logo-full {
    width: 100%;
    max-width: 100%;
    height: 67px;
    object-fit: contain;
    object-position: center;
    display: block;
}
.crm-sidebar-brand .crm-logo-mark {
    display: none;
    width: 40px;
    height: 40px;
    object-fit: contain;
}
.crm-nav-label {
    margin: 12px 22px 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    color: #93a0c0;
}
.crm-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin: 2px 12px;
    border-radius: 12px;
    color: #d7deef;
    font-size: 14px;
}
.crm-nav-item i { width: 18px; text-align: center; opacity: .9; }
.crm-nav-item .crm-nav-badge {
    margin-left: auto;
    min-width: 20px;
    height: 20px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}
.crm-nav-item.is-active {
    background: var(--crm-orange);
    color: #1a2438;
    font-weight: 600;
}
.crm-nav-item.is-active i {
    color: #fff;
    opacity: 1;
}
.crm-nav-item.is-disabled {
    opacity: .42;
    cursor: not-allowed;
}
.crm-version {
    margin-top: auto;
    padding: 18px 22px 4px;
    font-size: 11px;
    color: #8e9bb8;
}

.crm-content {
    flex: 1;
    min-width: 0;
    min-height: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.crm-topbar {
    height: 68px;
    flex-shrink: 0;
    background: #fff;
    border-bottom: 1px solid var(--crm-border);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 22px;
    position: relative;
    z-index: 1030;
}
.crm-menu-toggle {
    width: 38px;
    height: 38px;
    border: 0;
    background: transparent;
    color: #5b6680;
    border-radius: 8px;
}
.crm-menu-toggle:hover { background: #f2f4f8; }
.crm-global-search {
    flex: 1;
    max-width: 560px;
    height: 42px;
    border-radius: 10px;
    background: #f3f5f8;
    color: var(--crm-muted);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
}
.crm-global-search input {
    border: 0;
    background: transparent;
    outline: none;
    width: 100%;
    color: var(--crm-text);
}
.crm-topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.crm-icon-btn {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #62708b;
    position: relative;
}
.crm-icon-btn .crm-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 16px;
    height: 16px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}
.crm-profile-menu {
    position: relative;
}
.crm-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 6px 4px 8px;
    border: 0;
    background: transparent;
    cursor: pointer;
    border-radius: 10px;
}
.crm-profile:hover { background: #f3f5f8; }
.crm-profile-menu.is-open .crm-profile { background: #f3f5f8; }
.crm-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--crm-navy);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}
.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-profile-dropdown-divider {
    height: 1px;
    background: var(--crm-line-soft);
    margin: 6px 4px;
}

.crm-main {
    flex: 1;
    min-height: 0;
    padding: 14px 24px 28px;
    overflow-x: hidden;
    overflow-y: auto;
}
.crm-main:has(.crm-page-toolbar) {
    padding-top: 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-toolbar {
    position: sticky;
    top: 0;
    z-index: 25;
    margin: 0 -24px;
    padding: 14px 24px 12px;
    background: var(--crm-bg);
    border-bottom: 1px solid var(--crm-border);
    box-shadow: 0 6px 16px rgba(31, 42, 68, 0.04);
}
.crm-page-toolbar .crm-breadcrumb {
    margin-bottom: 8px;
}
.crm-page-toolbar .crm-page-header {
    margin-bottom: 0;
}
.crm-main:has(.crm-page-toolbar) > form {
    padding-top: 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;
}
.crm-card-title-help {
    margin: 0;
    font-size: 12px;
    font-weight: 500;
    color: var(--crm-muted);
    white-space: nowrap;
}
.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-advanced-filter {
    height: 36px;
    flex-shrink: 0;
    border: 1px solid var(--crm-border);
    border-radius: 10px;
    background: #fff;
    color: #5b6680;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}
.crm-advanced-filter:hover {
    border-color: #cfd8e6;
    background: #fbfcfe;
}
.crm-advanced-filter.is-active {
    border-color: #f3b56a;
    background: #fff7ee;
    color: #c47a12;
}
.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-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 16px;
    margin: 0;
    padding: 12px 16px 14px;
    border-top: 1px solid #e8edf3;
    background: transparent;
}
.crm-filter-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    min-width: 160px;
    max-width: none;
    flex: 1 1 0;
}
.crm-filter-field > span {
    font-size: 12px;
    font-weight: 700;
    color: #6b758c;
}
.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;
}
/* Cam “đã chọn” chỉ dùng ở bộ lọc list — không áp form nhập liệu */
.crm-filter-fields .crm-select.is-active .crm-select-trigger {
    border-color: rgba(243, 146, 33, 0.55);
    background: #fffaf4;
    box-shadow: 0 0 0 3px rgba(243, 146, 33, 0.1);
}
.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-advanced-filter {
        margin-left: 0;
        justify-content: center;
    }
    .crm-filter-actions {
        width: 100%;
        justify-content: flex-end;
    }
    .crm-filter-field {
        flex: 1 1 calc(50% - 16px);
        max-width: none;
    }
}

.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-flash {
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
}
.crm-flash.is-ok {
    background: #eefaf1;
    color: #1f7a3c;
    border: 1px solid #c8ebd2;
}
.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-col-code { width: 120px; min-width: 120px; }
.crm-table .crm-col-name { width: 160px; min-width: 160px; }
.crm-table .crm-col-phone { width: 120px; min-width: 120px; }
.crm-table .crm-col-email { width: 180px; min-width: 180px; }
.crm-table .crm-col-dept { width: 130px; min-width: 130px; }
.crm-table .crm-col-pos { width: 130px; min-width: 130px; }
.crm-table .crm-col-revenue { width: 130px; min-width: 130px; }
.crm-table .crm-col-manager { width: 140px; min-width: 140px; }
.crm-table .crm-col-commission { width: 150px; min-width: 150px; }
.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-table .crm-action-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 7px;
    font-size: 13px;
    line-height: 1;
}
.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-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: 18px;
}
.crm-form-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
}
.crm-form-stack > .crm-card {
    margin-bottom: 0;
}
.crm-note-card .crm-note-body {
    margin: 0;
    padding-top: 0;
    color: var(--crm-text);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.45;
}
.crm-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 16px;
}
.crm-fields-single {
    grid-template-columns: 1fr;
}
/* HR-02: thẻ 1–3 — lưới 3 cột field (Figma 1150:2) */
.crm-fields-3 {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}
.crm-fields-3 > .crm-field {
    grid-column: span 2;
}
.crm-fields-3 > .crm-field-half {
    grid-column: span 3;
}
.crm-form-grid-compact .crm-field input,
.crm-form-grid-compact .crm-field select {
    min-height: 36px;
    height: 36px;
    padding-top: 0;
    padding-bottom: 0;
    font-size: 13px;
    line-height: 1.2;
    border-radius: 8px;
}
.crm-form-grid-compact .crm-field select {
    height: 36px;
    padding-right: 32px;
    background-position: right 10px center;
    background-size: 13px;
}
.crm-form-grid-compact .crm-field input[type="file"] {
    height: auto;
    min-height: 0;
    padding-top: 6px;
    padding-bottom: 6px;
}
.crm-form-grid-compact .crm-field .crm-select-trigger {
    height: 36px;
    padding: 0 11px;
    font-size: 13px;
    border-radius: 8px;
}
.crm-fields .crm-field-full,
.crm-fields-3 > .crm-field-full { grid-column: 1 / -1; }

/* 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; }
.crm-field .is-readonly {
    background: #f5f7fa;
    color: #6b758c;
}
.crm-help { color: var(--crm-muted); font-size: 12px; margin-top: 6px; }

.crm-profile-card {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}
.crm-employee-hero {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.crm-profile-main {
    display: flex;
    gap: 14px;
    align-items: center;
    min-width: 0;
    flex: 1;
}
.crm-profile-main > div {
    flex: 1;
    min-width: 0;
}
.crm-profile-avatar {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: var(--crm-navy);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 800;
    flex-shrink: 0;
}
.crm-profile-avatar-img {
    width: 48px;
    height: 64px;
    padding: 0;
    overflow: hidden;
    background: #f0f2f6;
    border: 1px solid #e6ebf2;
    border-radius: 10px;
}
.crm-profile-avatar-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.crm-profile-main h2 {
    margin: 0;
    font-size: 20px;
    line-height: 1.25;
    font-weight: 800;
}
.crm-profile-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 10px;
    margin-bottom: 4px;
}
.crm-badges {
    display: inline-flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 0;
}
.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-profile-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0;
    color: var(--crm-muted);
    font-size: 13px;
    line-height: 1.5;
    margin-top: 2px;
}
.crm-profile-meta > span {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}
.crm-profile-meta > span:not(:last-child)::after {
    content: "·";
    margin: 0 8px;
    color: #c2c9d6;
}
.crm-profile-card .crm-page-actions { flex-shrink: 0; }
.crm-btn-danger-soft {
    color: #d04a4a;
    border-color: #f2b7b7;
    background: #fff;
}
.crm-btn-danger-soft:hover {
    color: #b73a3a;
    border-color: #e79d9d;
    background: #fff5f5;
}

.crm-stat-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    margin-top: 14px;
    border-top: 1px solid var(--crm-border);
    padding-top: 12px;
}
.crm-stat-row > div {
    padding: 0 16px;
    border-right: 1px solid var(--crm-border);
}
.crm-stat-row > div:first-child { padding-left: 0; }
.crm-stat-row > div:last-child { border-right: 0; padding-right: 0; }
.crm-stat-row span {
    display: block;
    color: var(--crm-muted);
    font-size: 12px;
    margin-bottom: 4px;
}
.crm-stat-row strong {
    font-size: 16px;
    font-weight: 800;
    line-height: 1.2;
}

.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-tabs .crm-tab-count {
    display: inline-flex;
    margin-left: 6px;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #eef1f5;
    color: #62708b;
    font-size: 11px;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}
.crm-tabs-hero {
    gap: 28px;
    margin: 0;
    border-bottom: 0;
    padding-top: 2px;
}
.crm-tabs-hero a {
    padding: 0 0 10px;
}

.crm-employee-stats {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}
.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-detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 12px;
    align-items: start;
}
.crm-detail-main {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}
.crm-detail-main > .crm-card,
.crm-detail-grid > .crm-card {
    margin-bottom: 0;
}
.crm-kv {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 24px;
    margin: 0;
}
.crm-kv-personal {
    align-items: start;
}
.crm-kv-col {
    display: grid;
    gap: 12px;
    margin: 0;
}
.crm-kv-col > div,
.crm-kv > div {
    padding: 0;
    border: 0;
}
.crm-kv dt,
.crm-kv-col dt {
    margin: 0 0 2px;
    color: var(--crm-muted);
    font-size: 12px;
}
.crm-kv dd,
.crm-kv-col dd {
    margin: 0;
    font-weight: 600;
    font-size: 13px;
    line-height: 1.35;
}
.crm-kv .crm-field-full {
    grid-column: 1 / -1;
}
.crm-info-grid {
    display: grid;
    gap: 16px 18px;
    margin: 0;
}
.crm-info-grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}
.crm-info-grid > div {
    min-width: 0;
}
.crm-info-grid dt {
    margin: 0 0 4px;
    color: var(--crm-muted);
    font-size: 12px;
    line-height: 1.35;
}
.crm-info-grid dd {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    word-break: break-word;
}
.crm-card-head-meta {
    color: var(--crm-muted);
    font-size: 12px;
    line-height: 1.4;
}

/* Phòng ban / KV hàng: phân cách nội dung (inset trong padding card) */
.crm-kv-rows {
    display: grid;
    gap: 0;
    margin: 0;
}
.crm-kv-rows > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 34px;
    padding: 6px 0;
    border: 0;
}
.crm-kv-rows > div:first-child { padding-top: 2px; }
.crm-kv-rows > div:last-child { padding-bottom: 0; }
.crm-kv-rows dt {
    margin: 0;
    color: var(--crm-muted);
    font-size: 13px;
    font-weight: 500;
    flex: 0 1 auto;
}
.crm-kv-rows dd {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    text-align: right;
    color: var(--crm-text);
}
.crm-kv-rows > div.is-section-start {
    margin-top: 6px;
    padding-top: 10px;
    border-top: 1px solid var(--crm-border);
}
.crm-side-card-actions {
    margin-top: 12px;
}
.crm-history-table td:nth-child(2) {
    white-space: nowrap;
}
.crm-history-table .crm-badge {
    font-weight: 700;
}
.crm-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 28, 48, .45);
    z-index: 1035;
}

/* Sidebar thu gọn — chỉ class trên <html> (FOUC + JS) */
html.sidebar-collapsed .crm-sidebar,
html.sidebar-collapsed .crm-sidebar-brand {
    width: var(--crm-sidebar-collapsed-width);
}
html.sidebar-collapsed .crm-sidebar-brand {
    height: 67px;
    justify-content: center;
    align-items: center;
    padding: 0;
    margin: 0 auto;
}
html.sidebar-collapsed .crm-sidebar-brand .crm-logo-full { display: none; }
html.sidebar-collapsed .crm-sidebar-brand .crm-logo-mark {
    display: block;
    width: 36px;
    height: 36px;
    margin: 0 auto;
    object-fit: contain;
    object-position: center;
}
html.sidebar-collapsed .crm-nav-label,
html.sidebar-collapsed .crm-nav-item span,
html.sidebar-collapsed .crm-nav-badge,
html.sidebar-collapsed .crm-version { display: none; }
html.sidebar-collapsed .crm-nav-item {
    justify-content: center;
    margin-left: 8px;
    margin-right: 8px;
    padding-left: 0;
    padding-right: 0;
}

.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-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        transition: transform .2s ease;
    }
    body.sidebar-open .crm-sidebar { transform: translateX(0); }
    body.sidebar-open .crm-sidebar-backdrop { display: block; }
    .crm-form-grid,
    .crm-detail-grid,
    .crm-stat-row,
    .crm-employee-stats,
    .crm-info-grid,
    .crm-fields,
    .crm-fields-3 { grid-template-columns: 1fr; }
    .crm-fields-3 > .crm-field,
    .crm-fields-3 > .crm-field-half,
    .crm-fields-3 > .crm-field-full { grid-column: auto; }
    .crm-stat-row > div { border-right: 0; border-bottom: 1px solid var(--crm-border); padding: 12px 0; }
    .crm-profile-card { flex-direction: column; }
    .crm-page-header { align-items: flex-start; flex-direction: column; }
    .crm-tabs-hero { gap: 18px; }
}

/* 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-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

/* Form inline mở/đóng bằng <details> */
.crm-inline-details { position: relative; display: inline-block; }
.crm-inline-details summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.crm-inline-details summary::-webkit-details-marker { display: none; }
.crm-inline-details .crm-inline-form {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 60;
    width: min(520px, 92vw);
    padding: 16px;
    background: #fff;
    border: 1px solid var(--crm-border);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(24, 34, 63, 0.16);
    text-align: left;
}
.crm-inline-details .crm-inline-form .crm-fields { margin-bottom: 12px; }
.crm-inline-details-right .crm-inline-form { right: 0; left: auto; }

/* Chip lọc loại hoạt động */
.crm-chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.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;
}

/* Timeline hoạt động */
.crm-timeline { list-style: none; margin: 0; padding: 0; }
.crm-timeline-item { display: flex; gap: 12px; position: relative; padding-bottom: 18px; }
.crm-timeline-item:not(:last-child)::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 32px;
    bottom: 0;
    width: 2px;
    background: var(--crm-border);
}
.crm-timeline-icon {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eef1f5;
    color: var(--crm-navy);
    font-size: 13px;
    z-index: 1;
}
.crm-timeline-body { flex: 1; min-width: 0; }
.crm-timeline-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 2px; }

/* Empty state */
.crm-empty-state {
    text-align: center;
    padding: 34px 12px;
    color: #8a93a6;
}
.crm-empty-state i { font-size: 30px; margin-bottom: 10px; display: block; }
.crm-empty-state p { margin: 0; }

/* Dropzone file đính kèm (BR-07) */
.crm-dropzone-form { margin-bottom: 18px; }
.crm-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 26px 12px;
    border: 2px dashed var(--crm-border);
    border-radius: 12px;
    cursor: pointer;
    text-align: center;
    margin-bottom: 12px;
    font-weight: 600;
    color: var(--crm-navy);
}
.crm-dropzone:hover { border-color: var(--crm-orange); }
.crm-dropzone i { font-size: 24px; color: var(--crm-orange); }
.crm-dropzone input[type="file"] { margin-top: 8px; }

/* Nhóm checkbox gán vai */
.crm-check-group { display: flex; gap: 16px; flex-wrap: wrap; }

.crm-btn-sm {
    height: 32px;
    padding: 0 12px;
    font-size: 12px;
}
.crm-btn-block {
    width: 100%;
    justify-content: center;
}

/* HR-02 thẻ 4 — Ảnh & Hồ sơ đính kèm */
.crm-photo-upload {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}
.crm-photo-preview {
    flex: 0 0 72px;
    width: 72px;
    height: 96px;
    border-radius: 8px;
    background: #f0f2f6;
    border: 1px solid #e6ebf2;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: #9aa3b8;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    line-height: 1.3;
    padding: 6px;
}
.crm-photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.crm-photo-meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}
.crm-photo-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--crm-text);
}
.crm-photo-hint {
    font-size: 12px;
    color: var(--crm-muted);
    margin-bottom: 4px;
}
.crm-photo-btn {
    cursor: pointer;
    margin: 0;
}
.crm-doc-section {
    border-top: 1px solid var(--crm-line-soft);
    padding-top: 12px;
}
.crm-doc-checklist {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}
.crm-doc-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    cursor: pointer;
    font-weight: 500;
    color: var(--crm-text);
    font-size: 13px;
    line-height: 1.35;
}
.crm-doc-check input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}
.crm-doc-box {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    margin-top: 1px;
    border: 1.5px solid #cfd6e4;
    border-radius: 4px;
    background: #fff;
    position: relative;
    transition: border-color .12s ease, background-color .12s ease;
}
.crm-doc-box::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0);
    transition: transform .12s ease;
}
.crm-doc-check input:checked + .crm-doc-box {
    background: var(--crm-orange);
    border-color: var(--crm-orange);
}
.crm-doc-check input:checked + .crm-doc-box::after {
    transform: rotate(45deg) scale(1);
}
.crm-doc-check input:focus-visible + .crm-doc-box {
    box-shadow: 0 0 0 3px rgba(243, 146, 33, 0.2);
}
.crm-doc-text .req { color: #e14b4b; }
.crm-doc-upload-btn {
    height: 36px;
    border-style: solid;
}
.crm-doc-upload-btn:disabled {
    opacity: .7;
    cursor: not-allowed;
}

/* Modal cắt ảnh chân dung 3x4 */
.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;
}

/* Toggle hàng bộ lọc nâng cao */
.crm-filter-row.is-hidden { display: none; }

/* 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; }
