/* CRM Module Styles */

.crm-view-root {
    min-width: 0;
    width: 100%;
}

.crm-loading {
    min-height: 220px;
    display: grid;
    place-items: center;
    color: var(--muted);
    border: 1px solid var(--line);
    background: var(--paper);
    box-shadow: var(--shadow);
}

.crm-view-root .page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.crm-view-root .page-header h1 {
    font-size: 25px;
}

.crm-view-root .page-header p {
    margin: 5px 0 0;
}

.crm-view-root .btn {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 13px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--ink);
    background: var(--paper);
    font-weight: 600;
    text-decoration: none;
}

.crm-view-root .btn:hover:not(:disabled) {
    border-color: #aec3be;
    background: #f9fbfa;
}

.crm-view-root .btn:active:not(:disabled) {
    transform: translateY(1px);
}

.crm-view-root .btn:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.crm-view-root .btn-primary,
.crm-view-root .btn-success {
    border-color: var(--brand);
    color: #fff;
    background: var(--brand);
}

.crm-view-root .btn-primary:hover:not(:disabled),
.crm-view-root .btn-success:hover:not(:disabled) {
    border-color: var(--brand-dark);
    background: var(--brand-dark);
}

.crm-view-root .btn-secondary {
    color: var(--ink);
    background: var(--paper);
}

.crm-view-root .btn-warning {
    border-color: #e8cf9d;
    color: #795510;
    background: #fff9e9;
}

.crm-view-root .btn-danger {
    border-color: #f1c8c8;
    color: var(--red);
    background: #fff8f8;
}

.crm-view-root .btn-link {
    min-height: 30px;
    padding: 4px 7px;
    border-color: transparent;
    color: var(--brand-dark);
    background: transparent;
}

.crm-view-root .btn-sm {
    min-height: 31px;
    padding: 5px 9px;
    font-size: 12px;
}

.crm-view-root .form-group {
    margin-bottom: 16px;
}

.crm-view-root .form-group > label,
.crm-view-root .form-group > .form-label {
    display: block;
    margin-bottom: 6px;
    color: var(--ink);
    font-size: 12px;
    font-weight: 700;
}

.crm-view-root .form-control {
    width: 100%;
    min-height: 38px;
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    background: var(--paper);
    outline: none;
}

.crm-view-root textarea.form-control {
    min-height: 82px;
    resize: vertical;
}

.crm-view-root .form-control:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(8, 127, 149, .1);
}

.crm-view-root .row {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 14px;
}

.crm-view-root .col-md-2 { grid-column: span 2; }
.crm-view-root .col-md-3 { grid-column: span 3; }
.crm-view-root .col-md-4 { grid-column: span 4; }
.crm-view-root .col-md-5 { grid-column: span 5; }
.crm-view-root .col-md-6 { grid-column: span 6; }
.crm-view-root .col-md-8 { grid-column: span 8; }
.crm-view-root .col-md-10 { grid-column: span 10; }
.crm-view-root .col-md-12 { grid-column: 1 / -1; }

.crm-view-root .card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--paper);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.crm-view-root .card-header {
    min-height: 48px;
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    background: #f8fafb;
}

.crm-view-root .nav-tabs {
    display: flex;
    gap: 4px;
    border: none;
    margin: 0;
    padding: 0;
}

.crm-view-root .nav-link {
    padding: 10px 18px;
    border: none;
    border-bottom: 3px solid transparent;
    background: transparent;
    color: var(--muted);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.crm-view-root .nav-link:hover {
    color: var(--ink);
    background: rgba(0, 0, 0, 0.03);
}

.crm-view-root .nav-link.active {
    color: var(--brand);
    border-bottom-color: var(--brand);
    background: transparent;
    font-weight: 700;
}

.crm-view-root .card-header-tabs {
    margin: -12px -16px -12px;
    border-bottom: none;
}

.crm-view-root .card-header h5,
.crm-view-root .card-body h5 {
    margin: 0;
    font-family: Manrope, sans-serif;
    font-size: 15px;
}

.crm-view-root .card-body {
    padding: 18px;
}

.crm-project-form-tabs {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 6px;
}

.crm-project-form-tab {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 14px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--ink);
    background: var(--paper);
    font-weight: 700;
    text-align: center;
    cursor: pointer;
}

.crm-project-form-tab:hover {
    border-color: var(--brand);
    color: var(--brand-dark);
    background: #f1f9fa;
}

.crm-project-form-tab:focus-visible {
    border-color: var(--brand);
    outline: none;
    box-shadow: 0 0 0 3px rgba(8, 127, 149, .16);
}

.crm-project-form-tab:active {
    transform: translateY(1px);
}

.crm-project-form-tab.active,
.crm-project-form-tab.active:hover {
    border-color: var(--brand-dark);
    color: #fff;
    background: var(--brand-dark);
}

.crm-view-root .table-responsive {
    overflow: auto;
    border: 1px solid var(--line);
    background: var(--paper);
    box-shadow: var(--shadow);
}

.crm-view-root .table-responsive table {
    min-width: 880px;
}

.crm-view-root .table-borderless th,
.crm-view-root .table-borderless td {
    border-bottom: 0;
    background: transparent;
    text-transform: none;
    letter-spacing: normal;
    font-size: 13px;
}

.crm-view-root .badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.crm-view-root .badge-success { color: #146b43; background: #def4e8; }
.crm-view-root .badge-primary { color: #0b6070; background: #dff3f5; }
.crm-view-root .badge-info { color: #23628a; background: #e3f1fb; }
.crm-view-root .badge-warning { color: #805a0e; background: #fff0c9; }
.crm-view-root .badge-danger { color: #a83b3b; background: #fbe6e6; }
.crm-view-root .badge-secondary { color: #56667a; background: #e9eef3; }
.crm-view-root .badge-purple { color: #684ea4; background: #eee9fa; }

.crm-view-root .alert,
.crm-alert {
    margin-bottom: 16px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--paper);
}

.crm-view-root .alert p,
.crm-alert p {
    margin: 5px 0 0;
}

.crm-view-root .alert-danger,
.crm-alert-danger {
    border-color: #f1c8c8;
    color: #963838;
    background: #fff8f8;
}

.crm-view-root .alert-warning {
    border-color: #e8cf9d;
    color: #795510;
    background: #fff9e9;
}

.crm-view-root .form-check-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 4px 18px 4px 0;
}

.crm-view-root .form-check-label {
    margin: 0;
    font-weight: 500;
}

.crm-view-root .d-flex { display: flex; }
.crm-view-root .d-flex.gap-2 { gap: 8px; }
.crm-view-root .page-header > .d-flex { flex-wrap: wrap; }
.crm-view-root .align-items-center { align-items: center; }
.crm-view-root .align-items-end { align-items: flex-end; }
.crm-view-root .justify-content-between { justify-content: space-between; }
.crm-view-root .text-center { text-align: center; }
.crm-view-root .text-right { text-align: right; }
.crm-view-root .text-muted { color: var(--muted); }
.crm-view-root .text-danger { color: var(--red); }
.crm-view-root .w-100 { width: 100%; }
.crm-view-root .d-none { display: none; }
.crm-view-root .py-5 { padding-top: 44px; padding-bottom: 44px; }
.crm-view-root .mt-3 { margin-top: 14px; }
.crm-view-root .mb-3 { margin-bottom: 14px; }
.crm-view-root .mb-4 { margin-bottom: 18px; }
.crm-view-root .mx-3 { margin-left: 12px; margin-right: 12px; }

.crm-view-root hr {
    margin: 22px 0;
    border: 0;
    border-top: 1px solid var(--line);
}

.crm-customer-card {
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.crm-customer-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.crm-badge-individual {
    background-color: #17a2b8;
}

.crm-badge-business {
    background-color: #28a745;
}

.crm-badge-partner {
    background-color: #6f42c1;
}

.crm-contact-item {
    padding: 8px 12px;
    border-left: 3px solid #007bff;
    background-color: #f8f9fa;
    margin-bottom: 8px;
}

.crm-duplicate-warning {
    border-left: 4px solid #ffc107;
    background-color: #fff3cd;
    padding: 12px;
    margin-bottom: 16px;
}

.crm-action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.crm-project-detail-header {
    align-items: flex-start;
    gap: 24px;
    padding: 18px 20px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--paper);
    box-shadow: 0 5px 18px rgba(16, 42, 67, .045);
}
.crm-project-detail-heading {
    flex: 1 1 560px;
    min-width: 0;
}
.crm-project-detail-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.crm-project-detail-title h1 {
    min-width: 0;
    margin: 0;
    color: var(--ink);
    font-family: Manrope, sans-serif;
    font-size: 30px;
    line-height: 1.15;
    overflow-wrap: anywhere;
}
.crm-project-detail-title .badge {
    margin: 0;
    white-space: nowrap;
}
.crm-project-detail-customer {
    margin-top: 8px;
    color: var(--muted);
    font-size: 13px;
}
.crm-project-detail-customer strong {
    color: var(--ink);
    font-weight: 800;
}
.crm-project-detail-metrics {
    display: grid;
    grid-template-columns: repeat(5, minmax(105px, 1fr));
    gap: 8px;
    margin-top: 16px;
}
.crm-project-detail-metric {
    min-width: 0;
    display: grid;
    gap: 4px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--canvas);
}
.crm-project-detail-metric span {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    line-height: 1.2;
}
.crm-project-detail-metric strong {
    color: var(--ink);
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
}
.crm-project-detail-metric.is-total {
    border-color: #acd8c0;
    background: #f2fbf6;
}
.crm-project-detail-metric.is-total strong {
    color: #146b43;
}
.crm-project-detail-actions {
    flex: 0 1 520px;
    align-self: flex-start;
    align-items: flex-start;
    align-content: flex-start;
    justify-content: flex-start;
    gap: 10px;
    height: max-content;
    padding-top: 0;
}
.crm-project-detail-actions__group {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
}
.crm-project-detail-actions__group--record {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}
.crm-project-detail-actions__row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
}
.crm-project-detail-actions__row .crm-project-detail-actions__group--workflow {
    display: contents;
}
.crm-project-detail-actions__row .crm-project-detail-actions__group--navigation {
    display: contents;
}
.crm-project-detail-actions__group .btn {
    width: 100%;
    min-width: 0;
}
.crm-project-detail-actions .btn {
    white-space: nowrap;
}
.crm-project-detail-actions .btn-primary {
    border-color: #087f95;
    background: #087f95;
}
.crm-project-detail-actions .btn-primary:hover:not(:disabled) {
    border-color: #056272;
    background: #056272;
}
.crm-project-detail-actions .btn-success {
    border-color: #a9d8bf;
    color: #176b49;
    background: #eef9f3;
}
.crm-project-detail-actions .btn-success:hover:not(:disabled) {
    border-color: #7fbe9f;
    background: #e1f3e9;
}
.crm-project-detail-actions .btn-danger {
    border-color: #e8b7bc;
    color: #a33b43;
    background: #fff3f3;
}
.crm-project-detail-actions .btn-danger:hover:not(:disabled) {
    border-color: #d78990;
    background: #ffe7e8;
}
.crm-project-detail-actions .btn-warning {
    border-color: #c58a2b;
    color: #704b0d;
    background: #fff7e2;
}
.crm-project-detail-actions .btn-warning:hover:not(:disabled) {
    border-color: #a96f16;
    background: #ffefc2;
}
.crm-project-detail-actions .btn-info {
    border-color: #4d7c9e;
    color: #28526f;
    background: #edf5fa;
}
.crm-project-detail-actions .btn-info:hover:not(:disabled) {
    border-color: #356785;
    background: #dfedf5;
}
.crm-project-detail-actions__group--record .btn-secondary {
    background: #f7f9fb;
}
.crm-project-detail-actions__group--navigation .btn-secondary {
    color: #475569;
    background: #eef2f5;
}
@media (max-width: 1100px) {
    .crm-project-detail-metrics {
        grid-template-columns: repeat(3, minmax(110px, 1fr));
    }
    .crm-project-detail-actions {
        flex-basis: 100%;
        justify-content: flex-start;
    }
    .crm-project-detail-actions__group--record,
    .crm-project-detail-actions__row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 640px) {
    .crm-project-detail-header {
        padding: 15px;
    }
    .crm-project-detail-title h1 {
        font-size: 23px;
    }
    .crm-project-detail-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        margin-top: 13px;
    }
    .crm-project-detail-actions .btn {
        flex: 1 1 auto;
    }
}

.crm-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.crm-customer-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.crm-customer-stat {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--paper);
    box-shadow: 0 5px 18px rgba(16, 42, 67, .045);
    transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.crm-customer-stat:hover {
    border-color: #c7d7e4;
    box-shadow: 0 8px 22px rgba(16, 42, 67, .075);
    transform: translateY(-1px);
}

.crm-customer-stats.is-error .crm-stat-value {
    color: var(--muted);
}

.crm-stat-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 8px;
}

.crm-stat-icon-primary { color: var(--brand-dark); background: rgba(8, 127, 149, .11); }
.crm-stat-icon-success { color: #146b43; background: rgba(20, 107, 67, .11); }
.crm-stat-icon-secondary { color: #56667a; background: rgba(86, 102, 122, .11); }
.crm-stat-icon-info { color: #23628a; background: rgba(35, 98, 138, .11); }

.crm-stat-copy,
.crm-stat-label,
.crm-stat-value {
    display: block;
}

.crm-stat-copy {
    min-width: 0;
}

.crm-stat-label {
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-stat-value {
    margin-top: 3px;
    color: var(--ink);
    font-family: Manrope, sans-serif;
    font-size: 25px;
    font-variant-numeric: tabular-nums;
    line-height: 1.05;
}

.crm-filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px;
    margin-bottom: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--paper);
}

.filter-controls {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 auto;
}

.filter-search {
    min-width: 240px;
    flex: 1 1 40%;
}

.filter-select {
    min-width: 150px;
    flex: 0 1 170px;
}

.btn-icon-only {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    flex: 0 0 38px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--ink);
    background: var(--paper);
    cursor: pointer;
    transition: border-color .16s ease, background-color .16s ease, transform .16s ease;
}

.btn-icon-only:hover:not(:disabled),
.btn-icon-only:focus-visible {
    border-color: var(--brand);
    background: var(--canvas);
    outline: none;
}

.btn-icon-only:focus-visible {
    box-shadow: 0 0 0 3px rgba(8, 127, 149, .13);
}

.btn-icon-only:active:not(:disabled) {
    transform: translateY(1px);
}

.btn-icon-only:disabled {
    cursor: not-allowed;
    opacity: .45;
}

.filter-actions {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: 8px;
}

.crm-customer-list .crm-filter-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 18px;
    row-gap: 12px;
}

.crm-customer-list .filter-controls {
    display: grid;
    grid-template-columns: minmax(280px, 2fr) repeat(2, minmax(150px, .8fr)) 38px;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.crm-customer-list .filter-search,
.crm-customer-list .filter-select {
    width: 100%;
    min-width: 0;
}

.crm-customer-list .filter-actions {
    justify-content: flex-end;
    min-width: max-content;
}

.crm-customer-list .filter-actions > .btn {
    white-space: nowrap;
}

.filter-create-label-mobile {
    display: none;
}

.active-filters {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 12px;
    margin: -5px 0 16px;
    border: 1px solid rgba(8, 127, 149, .22);
    border-radius: 7px;
    background: rgba(223, 247, 250, .42);
}

.active-filters[hidden] {
    display: none;
}

.active-filters-label {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.active-filter-tags {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 7px;
    flex: 1 1 auto;
    flex-wrap: wrap;
}

.filter-tag {
    max-width: 100%;
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 5px 3px 9px;
    border: 1px solid rgba(8, 127, 149, .24);
    border-radius: 6px;
    color: var(--ink);
    background: var(--paper);
    font-size: 12px;
}

.filter-tag-remove {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    flex: 0 0 22px;
    padding: 0;
    border: 0;
    border-radius: 5px;
    color: var(--muted);
    background: transparent;
    font-size: 16px;
    line-height: 1;
}

.filter-tag-remove:hover,
.filter-tag-remove:focus-visible {
    color: var(--ink);
    background: var(--canvas);
    outline: none;
}

.clear-filter-button {
    flex: 0 0 auto;
    white-space: nowrap;
}

.crm-icon-refresh { --crm-icon: url('/static/icons/refresh.svg'); }
.crm-icon-users { --crm-icon: url('/static/icons/users-group.svg'); }
.crm-icon-check { --crm-icon: url('/static/icons/circle-check.svg'); }
.crm-icon-archive { --crm-icon: url('/static/icons/archive.svg'); }
.crm-icon-user-plus { --crm-icon: url('/static/icons/user-plus.svg'); }
.crm-icon-edit { --crm-icon: url('/static/icons/edit.svg'); }
.crm-icon-trash { --crm-icon: url('/static/icons/trash.svg'); }
.crm-icon-save { --crm-icon: url('/static/icons/device-floppy.svg'); }
.crm-icon-photo { --crm-icon: url('/static/icons/photo.svg'); }
.crm-icon-dots { --crm-icon: url('/static/icons/dots-vertical.svg'); }
.crm-icon-eye { --crm-icon: url('/static/icons/eye.svg'); }

.crm-table-skeleton {
    display: grid;
    gap: 1px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: var(--line);
}

.crm-table-skeleton span {
    height: 54px;
    display: block;
    background: linear-gradient(90deg, var(--paper) 20%, #f4f7fa 50%, var(--paper) 80%);
    background-size: 220% 100%;
    animation: crm-skeleton-shimmer 1.4s ease-in-out infinite;
}

@keyframes crm-skeleton-shimmer {
    from { background-position: 100% 0; }
    to { background-position: -100% 0; }
}

.customer-row {
    cursor: pointer;
    transition: background-color .14s ease;
}

.customer-row:hover,
.customer-row:focus-within {
    background: #f2fafb;
}

.customer-row:active {
    background: #e6f4f6;
}

.customer-row:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: -2px;
}

.crm-customer-code {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.crm-row-hint {
    color: var(--brand-dark);
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity .14s ease, transform .14s ease;
}

.customer-row:hover .crm-row-hint,
.customer-row:focus-visible .crm-row-hint {
    opacity: 1;
    transform: translateX(0);
}

.crm-customer-table .crm-customer-action-column {
    width: 58px;
    min-width: 58px;
    position: sticky;
    right: 0;
    z-index: 2;
    padding-right: 9px;
    padding-left: 9px;
    background: var(--paper);
    text-align: center;
}

.crm-customer-table thead .crm-customer-action-column {
    z-index: 3;
    background: #f8faf9;
}

.crm-customer-actions:focus-within {
    z-index: 6;
}

.customer-row:hover .crm-customer-action-column,
.customer-row:focus-within .crm-customer-action-column {
    background: #f2fafb;
}

.customer-row:active .crm-customer-action-column {
    background: #e6f4f6;
}

.crm-customer-table-shell.is-scrollable-x .crm-customer-action-column {
    box-shadow: -10px 0 16px -15px rgba(16, 42, 67, .72);
}

.crm-kebab {
    position: relative;
    display: inline-flex;
}

.crm-kebab-trigger {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 7px;
    color: var(--muted);
    background: transparent;
}

.crm-kebab-trigger:hover,
.crm-kebab-trigger:focus-visible,
.crm-kebab-trigger[aria-expanded="true"] {
    border-color: var(--line);
    color: var(--ink);
    background: var(--paper);
    outline: none;
}

.crm-kebab-trigger:focus-visible {
    box-shadow: 0 0 0 3px rgba(8, 127, 149, .13);
}

.crm-kebab-menu {
    width: 190px;
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    z-index: 8;
    display: grid;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--paper);
    box-shadow: 0 16px 36px rgba(16, 42, 67, .17);
    text-align: left;
}

.crm-kebab-menu.opens-up {
    top: auto;
    bottom: calc(100% + 5px);
}

.crm-kebab-menu[hidden] {
    display: none;
}

.crm-kebab-menu button {
    min-height: 36px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 9px;
    border: 0;
    border-radius: 6px;
    color: var(--ink);
    background: transparent;
    text-align: left;
}

.crm-kebab-menu button:hover,
.crm-kebab-menu button:focus-visible {
    background: var(--canvas);
    outline: none;
}

.crm-kebab-menu button.is-danger {
    color: var(--red);
}

.crm-kebab-menu button.is-danger:hover,
.crm-kebab-menu button.is-danger:focus-visible {
    background: #fff0f2;
}

.crm-kebab-menu .crm-icon {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
}

.crm-kebab-separator {
    height: 1px;
    display: block;
    margin: 5px 3px;
    background: var(--line);
}

.crm-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-top: 16px;
}

.crm-pagination-summary {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.crm-pagination-pages {
    display: flex;
    align-items: center;
    gap: 5px;
}

.crm-page-button {
    min-width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--ink);
    background: var(--paper);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.crm-page-button:hover:not(:disabled),
.crm-page-button:focus-visible {
    border-color: var(--brand);
    color: var(--brand-dark);
    outline: none;
}

.crm-page-button:focus-visible {
    box-shadow: 0 0 0 3px rgba(8, 127, 149, .13);
}

.crm-page-button.is-active {
    border-color: var(--brand-dark);
    color: #fff;
    background: var(--brand-dark);
}

.crm-page-button:disabled {
    cursor: not-allowed;
    opacity: .42;
}

.crm-page-nav {
    font-size: 20px;
    font-weight: 500;
}

.crm-page-ellipsis {
    min-width: 24px;
    color: var(--muted);
    text-align: center;
}

.crm-product-image-field {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    align-items: center;
    gap: 18px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--canvas);
}

.crm-product-image-preview {
    width: 180px;
    aspect-ratio: 4 / 3;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px dashed #b7c7d6;
    border-radius: 8px;
    color: var(--muted);
    background: var(--paper);
}

.crm-product-image-preview img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}
.crm-product-image-gallery {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3px;
}
.crm-product-image-gallery img {
    width: 100%;
    height: 100%;
    min-height: 0;
    object-fit: cover;
}

.crm-product-image-empty {
    padding: 14px;
    font-size: 12px;
    text-align: center;
}

.crm-product-image-control {
    min-width: 0;
    display: grid;
    gap: 8px;
}

.crm-product-name-cell {
    min-width: 210px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.crm-product-thumbnail {
    width: 46px;
    height: 38px;
    display: block;
    flex: 0 0 auto;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--canvas);
    object-fit: cover;
}

.crm-product-thumbnail-empty {
    background: var(--canvas) url('/static/icons/photo.svg') center / 18px no-repeat;
    opacity: .62;
}

.crm-project-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 15px 16px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--canvas);
}

.crm-project-total span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.crm-project-total strong {
    color: #146b43;
    font-family: Manrope, sans-serif;
    font-size: 22px;
}

@media (max-width: 900px) {
    .crm-customer-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .crm-filter-bar {
        align-items: stretch;
        flex-wrap: wrap;
    }

    .filter-controls,
    .filter-actions {
        width: 100%;
        flex-basis: 100%;
    }

    .filter-actions {
        justify-content: flex-end;
    }

    .crm-view-root .col-md-2,
    .crm-view-root .col-md-3,
    .crm-view-root .col-md-4,
    .crm-view-root .col-md-5,
    .crm-view-root .col-md-6,
    .crm-view-root .col-md-8,
    .crm-view-root .col-md-10 {
        grid-column: span 6;
    }
}

@media (max-width: 640px) {
    .crm-project-form-tabs {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .crm-project-form-tab {
        width: 100%;
        padding-right: 10px;
        padding-left: 10px;
    }

    .crm-customer-stats {
        grid-template-columns: 1fr;
        gap: 9px;
    }

    .crm-customer-stat {
        padding: 12px 14px;
    }

    .crm-filter-bar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 38px auto;
        gap: 8px;
    }

    .filter-controls {
        display: contents;
    }

    .filter-search {
        min-width: 0;
        grid-column: 1 / -1;
    }

    .filter-select {
        min-width: 0;
        width: 100%;
        padding-right: 7px;
        padding-left: 8px;
        font-size: 13px;
    }

    .filter-actions .btn {
        width: auto;
        min-width: 68px;
        padding-right: 9px;
        padding-left: 9px;
        white-space: nowrap;
    }

    .filter-actions {
        width: auto;
        grid-column: 4;
        flex-basis: auto;
    }

    .filter-create-label {
        display: none;
    }

    .filter-create-label-mobile {
        display: inline;
    }

    .active-filters {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .active-filter-tags {
        flex-basis: calc(100% - 72px);
    }

    .clear-filter-button {
        margin-left: auto;
    }

    .crm-view-root .page-header,
    .crm-pagination {
        align-items: stretch;
        flex-direction: column;
    }

    .crm-pagination-pages {
        justify-content: center;
        flex-wrap: wrap;
    }

    .crm-product-image-field {
        grid-template-columns: 1fr;
    }

    .crm-product-image-preview {
        width: min(100%, 320px);
    }

    .crm-view-root .row {
        grid-template-columns: 1fr;
    }

    .crm-view-root .col-md-2,
    .crm-view-root .col-md-3,
    .crm-view-root .col-md-4,
    .crm-view-root .col-md-5,
    .crm-view-root .col-md-6,
    .crm-view-root .col-md-8,
    .crm-view-root .col-md-10,
    .crm-view-root .col-md-12 {
        grid-column: 1;
    }
}

@media (max-width: 1200px) {
    .crm-customer-list .crm-filter-bar {
        grid-template-columns: 1fr;
    }

    .crm-customer-list .filter-controls,
    .crm-customer-list .filter-actions {
        width: 100%;
    }

    .crm-customer-list .filter-actions {
        justify-content: flex-end;
    }
}

@media (max-width: 640px) {
    .crm-customer-list .crm-filter-bar {
        grid-template-columns: 1fr;
    }

    .crm-customer-list .filter-controls {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 38px;
        gap: 8px;
    }

    .crm-customer-list .filter-search {
        grid-column: 1 / -1;
    }

    .crm-customer-list .filter-actions {
        grid-column: 1 / -1;
        min-width: 0;
        justify-content: stretch;
    }

    .crm-customer-list .filter-actions > .bulk-select-all {
        flex: 1 1 100%;
    }

    .crm-customer-list .filter-actions > .btn {
        flex: 1 1 140px;
        min-width: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .crm-customer-stat,
    .btn-icon-only,
    .customer-row,
    .crm-row-hint,
    .crm-project-form-tab {
        transition: none;
    }

    .crm-customer-stat:hover {
        transform: none;
    }

    .crm-table-skeleton span {
        animation: none;
        background: var(--canvas);
    }
}

/* Action History Timeline */
.crm-action-timeline {
    position: relative;
    padding-left: 30px;
}

.crm-action-timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--line);
}

.crm-action-timeline-item {
    position: relative;
    padding-bottom: 24px;
}

.crm-action-timeline-item:last-child {
    padding-bottom: 0;
}

.crm-action-timeline-marker {
    position: absolute;
    left: -26px;
    top: 2px;
    width: 18px;
    height: 18px;
    background: var(--canvas);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.crm-action-timeline-marker i {
    font-size: 18px;
}

.crm-action-timeline-content {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 16px;
}

.crm-action-timeline-content:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(196, 97, 47, 0.1);
    transition: all 0.2s ease;
}

/* ============================================
   PROJECT FORM — WIZARD STEPPER + PRICING
   ============================================ */

/* Header */
.prj-form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    margin-bottom: 8px;
}
.prj-form-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.3px;
}
.prj-form-code {
    font-size: 13px;
    color: var(--muted);
    margin-left: 10px;
}
.prj-form-header__actions {
    display: flex;
    gap: 8px;
}

/* Stepper */
.prj-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin: 0 0 28px;
    padding: 16px 0;
    border-bottom: 1px solid var(--line);
}
.prj-stepper__step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    transition: color 0.2s;
}
.prj-stepper__step.is-active {
    color: var(--ink);
    font-weight: 700;
}
.prj-stepper__step.is-done {
    color: var(--brand);
    cursor: pointer;
}
.prj-stepper__step.is-done .prj-stepper__num {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}
.prj-stepper__num {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid var(--line);
    font-size: 13px;
    font-weight: 700;
    transition: all 0.2s;
}
.prj-stepper__step.is-active .prj-stepper__num {
    border-color: var(--ink);
    background: var(--ink);
    color: #fff;
}
.prj-stepper__line {
    flex: 1;
    max-width: 60px;
    height: 2px;
    background: var(--line);
}
.prj-stepper__label {
    white-space: nowrap;
}

/* Panels */
.prj-panels {
    min-height: 300px;
}
.prj-panel[hidden] {
    display: none;
}

/* Footer */
.prj-form-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    margin-top: 24px;
    border-top: 1px solid var(--line);
}

/* ---- Pricing Section ---- */
.prj-pricing {
    padding: 4px 0;
}
.prj-pricing__empty {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 24px;
    color: var(--muted);
    font-size: 15px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    margin-bottom: 16px;
}

/* Business line section — flat grouped, no bounding box */
.prj-pricing__heading {
    margin: 0 0 20px;
    font-size: 18px;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -0.2px;
}
.prj-bl-group {
    margin-bottom: 28px;
}
.prj-bl-group__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    margin-bottom: 2px;
    border-bottom: 2px solid var(--bl-accent, var(--line));
}
.prj-bl-group__title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--bl-accent, var(--ink));
}
.prj-bl-group__icon {
    font-size: 14px;
    opacity: 0.8;
}
.prj-bl-group__add {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--paper);
    color: var(--ink);
    cursor: pointer;
    transition: all 0.15s;
}
.prj-bl-group__add:hover {
    border-color: var(--bl-accent, var(--brand));
    color: var(--bl-accent, var(--brand));
    background: #f9fafb;
}
.prj-bl-group__items {
    background: #fff;
}
.prj-bl-group__empty {
    color: var(--muted);
    font-size: 13px;
    font-style: italic;
    padding: 20px 0;
    margin: 0;
    text-align: center;
}
.prj-bl-group__subtotal {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-top: 1px solid var(--line);
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
}
.prj-bl-group__subtotal span:last-child {
    font-size: 15px;
    font-weight: 800;
    color: var(--ink);
}
.prj-bl-group__amounts,
.prj-pricing__grand-breakdown,
.crm-project-total-breakdown {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.prj-bl-group__amounts span,
.prj-pricing__grand-breakdown span,
.crm-project-total-breakdown span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}
.prj-pricing__grand-breakdown span { color: rgba(255,255,255,.72); }

/* Grand total */
.prj-pricing__grand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    margin: 24px 0 20px;
    background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
    color: #fff;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}
.prj-pricing__grand-value {
    font-size: 24px;
    font-weight: 900;
    letter-spacing: -0.5px;
    color: #10b981;
}

/* Quote summary rows shared by the editor and project detail. */
.pricing-summary {
    display: block;
}
.pricing-summary__title {
    margin-bottom: 8px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 800;
}
.pricing-summary__rows {
    display: grid;
    gap: 5px;
}
.pricing-summary__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 24px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}
.pricing-summary__row strong {
    color: var(--ink);
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}
.pricing-summary__row--total {
    margin-top: 4px;
    padding-top: 7px;
    border-top: 1px solid var(--line);
    color: var(--ink);
    font-weight: 800;
}
.pricing-summary__row--total strong {
    color: #146b43;
    font-size: 15px;
}
.prj-bl-group__summary {
    padding: 10px 0;
    border-top: 1px solid var(--line);
}
.prj-pricing__grand {
    display: block;
}
.prj-pricing__grand .pricing-summary__title,
.prj-pricing__grand .pricing-summary__row,
.prj-pricing__grand .pricing-summary__row strong {
    color: #fff;
}
.prj-pricing__grand .pricing-summary__row {
    border-color: rgba(255,255,255,.18);
}
.prj-pricing__grand .pricing-summary__row--total strong {
    color: #10b981;
    font-size: 18px;
}
.pricing-summary--table {
    padding: 6px 0;
}
.crm-project-total {
    display: block;
}
.crm-project-total .pricing-summary__title {
    text-transform: uppercase;
}
.crm-project-total .pricing-summary__row span {
    text-transform: none;
}
.crm-project-total .pricing-summary__row strong {
    font-size: 13px;
}
.crm-project-total .pricing-summary__row--total strong {
    color: #146b43;
    font-size: 15px;
}

/* ---- Attachment chips ---- */
.prj-attach-zone {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.prj-attach-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px dashed #b7c7d6;
    border-radius: 6px;
    background: #f9fafb;
    color: var(--brand-dark);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.prj-attach-btn:hover {
    border-color: var(--brand);
    background: #eff6ff;
}
.prj-attach-input {
    display: none;
}
.prj-attach-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.prj-attach-list-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    margin-right: 2px;
}
.prj-attach-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    font-size: 12px;
    font-weight: 500;
    color: var(--ink);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.prj-attach-chip:hover {
    border-color: var(--brand);
    background: #f0fafb;
}
.prj-attach-chip i {
    color: var(--brand);
    font-size: 12px;
}
.prj-attach-chip-name {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.prj-attach-chip--new {
    border-color: #93c5fd;
    background: #eff6ff;
}
.prj-attach-chip-remove {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    font-size: 11px;
    padding: 0;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}
.prj-attach-chip-remove span {
    display: block;
    line-height: 1;
}
.prj-attach-chip-remove:hover {
    color: #dc3545;
    background: #fee2e2;
}

/* Notes */
.prj-pricing__notes {
    margin-top: 16px;
}
.prj-pricing__notes label {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 4px;
}

/* ---- Inline Line Item (flat, separated by grey line) ---- */
.line-item-editor {
    margin-bottom: 0;
    padding: 14px 16px;
    border-radius: 0;
    background: transparent;
    border: none;
    border-bottom: 1px solid #cbd5e1;
    position: relative;
}
.line-item-editor:last-child {
    border-bottom: none;
}

/* Row layout */
.li-row__top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.li-row__bottom {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}

/* Fields */
.li-field {
    height: 36px;
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    font-size: 13px;
    background: #fff;
    font-weight: 500;
}
.li-field--bl {
    width: 120px;
    flex-shrink: 0;
}
.li-field--source {
    width: 150px;
    flex-shrink: 0;
}
.li-field--product {
    flex: 1;
    min-width: 240px;
    font-weight: 600;
}
.li-field--manual-name {
    flex: 1;
    min-width: 240px;
}
.li-field--manual-description {
    flex: 1;
    min-width: 220px;
}

.crm-address-picker {
    border: 0;
    padding: 0;
    margin-bottom: 1rem;
}
.crm-address-picker legend {
    font-weight: 600;
    margin-bottom: .45rem;
}
.crm-address-street {
    margin-bottom: .6rem;
}
.crm-address-street label,
.crm-address-grid label {
    display: block;
    font-size: .82rem;
    margin-bottom: .25rem;
}
.crm-address-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .6rem;
}
@media (max-width: 760px) {
    .crm-address-grid { grid-template-columns: 1fr; }
}
.li-row__description {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: -2px 0 10px;
}
.li-row__description .li-cell-label {
    min-width: 150px;
}
.li-row__description .li-field--manual-description {
    width: 100%;
}

/* Delete button - always visible */
.li-delete {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    background: none;
    color: #dc3545;
    opacity: 0.4;
    cursor: pointer;
    border-radius: 5px;
    flex-shrink: 0;
    margin-left: auto;
    transition: opacity 0.15s, background 0.15s, border-color 0.15s;
}
.li-delete:hover {
    opacity: 1;
    background: #fee2e2;
    border-color: #fca5a5;
}

/* Cell items */
.li-cell {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
}
.li-cell-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin: 0;
}
.li-cell--qty {
    width: 90px;
}
.li-cell--price {
    flex: 1;
    min-width: 110px;
}
.li-cell--unit {
    width: 90px;
}
.li-cell--discount {
    width: 140px;
}
.li-cell--vat {
    width: 75px;
}
.li-cell--subtotal,
.li-cell--vatamount {
    min-width: 115px;
    text-align: right;
}
.li-cell--total {
    min-width: 130px;
    text-align: right;
}

/* Inputs */
.li-input {
    height: 34px;
    padding: 4px 8px;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
    background: #fff;
    width: 100%;
}
.li-input--center {
    text-align: center;
}
.li-input--sm {
    width: 70px;
}
.li-input--xs {
    width: 55px;
}
.li-input:focus {
    border-color: var(--brand);
    outline: none;
    box-shadow: 0 0 0 2px rgba(8, 127, 149, .1);
}

/* Discount group */
.li-discount-group {
    display: flex;
    gap: 4px;
}

/* Price display (read-only) */
.li-price-display {
    font-size: 14px;
    font-weight: 700;
    color: var(--ink);
    padding: 6px 10px;
    background: #f9fafb;
    border-radius: 5px;
    border: 1px solid #e5e7eb;
    display: block;
    height: 34px;
    line-height: 22px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Total value */
.li-total-value {
    font-size: 15px;
    font-weight: 800;
    color: #047857;
    white-space: nowrap;
    padding: 6px 0;
    display: block;
}

/* Summary */
.prj-summary {
    padding: 24px;
    text-align: center;
}
.prj-summary h4 {
    margin-bottom: 20px;
    font-weight: 700;
}
.prj-summary__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    max-width: 400px;
    margin: 0 auto;
    text-align: left;
}
.prj-summary__item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.prj-summary__item .label {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
}

/* ---- Revenue Dashboard Chart ---- */
.rv-chart {
    padding: 12px 0;
}
.rv-chart__bars {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 6px;
    height: 190px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--line);
}
.rv-chart__col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.rv-chart__bar-pair {
    display: flex;
    align-items: flex-end;
    gap: 3px;
}
.rv-chart__bar {
    width: 16px;
    min-height: 2px;
    border-radius: 3px 3px 0 0;
    transition: height 0.3s ease;
    cursor: default;
}
.rv-chart__bar--actual { background: #10b981; }
.rv-chart__bar--expected { background: #60a5fa; }
.rv-chart__bar:hover { opacity: 0.8; }
.rv-chart__label {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
}
.rv-legend {
    display: flex;
    gap: 18px;
    justify-content: center;
    margin-top: 12px;
}
.rv-legend__item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
}
.rv-legend__dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    display: inline-block;
}

/* Project overview dashboard */
.crm-dashboard-header {
    align-items: flex-end;
}
.crm-dashboard-header h1 {
    margin-bottom: 4px;
}
.crm-dashboard-updated {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 10px;
}
.crm-dashboard-year {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--paper);
}
.crm-dashboard-year strong {
    min-width: 48px;
    text-align: center;
}
.crm-dashboard-year .btn {
    width: 30px;
    min-height: 30px;
    padding: 0;
    font-size: 20px;
    line-height: 1;
}
.crm-dashboard-kpi-grid,
.crm-dashboard-finance-grid {
    display: grid;
    gap: 12px;
    margin-bottom: 14px;
}
.crm-dashboard-kpi-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}
.crm-dashboard-finance-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}
.crm-dashboard-kpi,
.crm-finance-kpi {
    min-width: 0;
    padding: 15px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--paper);
}
.crm-dashboard-kpi {
    display: flex;
    align-items: center;
    gap: 12px;
}
.crm-dashboard-kpi > div:last-child,
.crm-finance-kpi {
    display: grid;
    gap: 4px;
}
.crm-dashboard-kpi span,
.crm-finance-kpi span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}
.crm-dashboard-kpi strong {
    display: block;
    color: var(--ink);
    font: 800 24px/1.1 Manrope, sans-serif;
}
.crm-dashboard-kpi small,
.crm-finance-kpi small {
    color: var(--muted);
    font-size: 10px;
}
.crm-finance-kpi strong {
    font: 800 17px/1.2 Manrope, sans-serif;
    white-space: nowrap;
}
.crm-finance-kpi--actual strong,
.crm-value-actual {
    color: #146b43;
}
.crm-finance-kpi--expected strong,
.crm-value-expected {
    color: #23628a;
}
.crm-finance-kpi--cost strong {
    color: #8a5b15;
}
.crm-finance-kpi--profit strong {
    color: #087f95;
}
.crm-finance-kpi--receivable strong {
    color: #a24141;
}
.crm-dashboard-section {
    margin-bottom: 14px;
}
.crm-dashboard-section .card-header {
    align-items: flex-start;
}
.crm-dashboard-section .card-header h2 {
    margin: 0;
    font-size: 15px;
}
.crm-dashboard-section .card-header p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 11px;
}
.crm-chart-note {
    display: block;
    max-width: 820px;
    margin-top: 5px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 400;
    line-height: 1.45;
    opacity: .78;
}
.crm-chart-note code {
    font-size: inherit;
    color: inherit;
}
.crm-definition-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 20px;
}
.crm-definition-item {
    min-width: 0;
    padding: 11px 0;
    border-bottom: 1px solid var(--line);
}
.crm-definition-item h3 {
    margin: 0 0 7px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 800;
}
.crm-definition-item dl {
    display: grid;
    gap: 4px;
    margin: 0;
}
.crm-definition-item dl > div {
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr);
    gap: 8px;
}
.crm-definition-item dt,
.crm-definition-item dd {
    margin: 0;
    font-size: 10px;
    line-height: 1.45;
}
.crm-definition-item dt {
    color: var(--muted);
    font-weight: 700;
}
.crm-definition-item dd {
    color: var(--muted);
    opacity: .9;
}
@media (max-width: 760px) {
    .crm-definition-grid { grid-template-columns: 1fr; }
}
.crm-dashboard-section-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}
.crm-dashboard-legend {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 11px;
    white-space: nowrap;
}
.crm-dashboard-legend span {
    width: 9px;
    height: 9px;
    display: inline-block;
    border-radius: 2px;
}
.crm-dashboard-legend .actual-dot {
    margin-left: 4px;
    background: #10b981;
}
.crm-dashboard-legend .expected-dot {
    margin-left: 8px;
    background: #60a5fa;
}
.crm-revenue-chart {
    overflow-x: auto;
    padding-bottom: 8px;
}
.crm-revenue-chart-bars {
    min-width: 680px;
    height: 210px;
    display: grid;
    grid-template-columns: repeat(12, minmax(38px, 1fr));
    align-items: end;
    gap: 10px;
    padding: 10px 8px 0;
    border-bottom: 1px solid var(--line);
}
.crm-revenue-chart-month {
    height: 100%;
    display: grid;
    grid-template-rows: 1fr auto;
    justify-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 10px;
}
.crm-revenue-bars {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: end;
    justify-content: center;
    gap: 3px;
}
.crm-bar {
    width: 11px;
    min-height: 0;
    display: block;
    border-radius: 3px 3px 0 0;
}
.crm-bar-actual {
    background: #10b981;
}
.crm-bar-expected {
    background: #60a5fa;
}
.crm-dashboard-table-wrap {
    margin-top: 14px;
}
.crm-dashboard-table {
    min-width: 700px;
}
.crm-pareto-chart {
    overflow-x: auto;
    padding-bottom: 8px;
}
.crm-pareto-svg {
    display: block;
    max-width: none;
    font-size: 11px;
}
.crm-pareto-grid line {
    stroke: var(--border, #e5e7eb);
    stroke-width: 1;
}
.crm-pareto-grid text,
.crm-pareto-axis,
.crm-pareto-label {
    fill: var(--muted, #6b7280);
}
.crm-pareto-value {
    fill: var(--text, #111827);
    font-weight: 600;
}
.crm-pareto-bar {
    opacity: 0.5;
}
.crm-pareto-bar.is-vital-few {
    opacity: 1;
}
.crm-pareto-bar rect.is-rent,
.crm-pareto-swatch.is-rent {
    fill: #3b82f6;
    background: #3b82f6;
}
.crm-pareto-bar rect.is-sale,
.crm-pareto-swatch.is-sale {
    fill: #10b981;
    background: #10b981;
}
.crm-pareto-bar rect.is-software,
.crm-pareto-swatch.is-software {
    fill: #8b5cf6;
    background: #8b5cf6;
}
.crm-pareto-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    vertical-align: middle;
}
.crm-pareto-threshold {
    stroke: #ef4444;
    stroke-width: 1.5;
    stroke-dasharray: 5 4;
}
.crm-pareto-line {
    fill: none;
    stroke: #f59e0b;
    stroke-width: 2.5;
}
.crm-pareto-point {
    fill: #fff;
    stroke: #f59e0b;
    stroke-width: 2;
}
.crm-pareto-line-dot {
    display: inline-block;
    width: 14px;
    height: 3px;
    border-radius: 2px;
    background: #f59e0b;
    vertical-align: middle;
}
.crm-project-count-chart {
    overflow-x: auto;
    padding-bottom: 8px;
}
.crm-project-count-chart-bars {
    min-width: 680px;
    height: 210px;
    display: grid;
    grid-template-columns: repeat(12, minmax(38px, 1fr));
    align-items: end;
    gap: 10px;
    padding: 10px 8px 0;
    border-bottom: 1px solid var(--line);
}
.crm-project-count-month {
    height: 100%;
    display: grid;
    grid-template-rows: 1fr auto;
    justify-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 10px;
}
.crm-project-count-slot {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: end;
    gap: 4px;
}
.crm-project-count-slot strong {
    color: var(--ink);
    font-size: 11px;
    line-height: 1;
}
.crm-project-count-slot span {
    width: 22px;
    min-height: 0;
    display: block;
    border-radius: 4px 4px 0 0;
    background: #c4612f;
}
.crm-dashboard-content-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.crm-dashboard-content-grid > .crm-dashboard-section {
    min-width: 0;
}
.crm-status-breakdown,
.crm-dashboard-metrics,
.crm-dashboard-list {
    display: grid;
    gap: 0;
}
.crm-status-row,
.crm-dashboard-metrics > div,
.crm-dashboard-list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}
.crm-status-row:last-child,
.crm-dashboard-metrics > div:last-child,
.crm-dashboard-list-row:last-child {
    border-bottom: 0;
}
.crm-status-row > div,
.crm-dashboard-list-row > span {
    min-width: 0;
    display: grid;
    gap: 3px;
}
.crm-status-progress {
    width: min(210px, 100%);
    height: 4px;
    margin-top: 5px;
    overflow: hidden;
    border-radius: 2px;
    background: #e8eef2;
}
.crm-status-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--brand);
}
.crm-status-row span,
.crm-dashboard-list-row small,
.crm-dashboard-metrics span {
    color: var(--muted);
    font-size: 11px;
}
.crm-dashboard-metrics strong {
    color: var(--ink);
    font-size: 13px;
    white-space: nowrap;
}
.crm-dashboard-list-row {
    width: 100%;
    border-top: 0;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
    color: var(--ink);
    background: transparent;
    text-align: left;
    cursor: pointer;
}
.crm-dashboard-list-row:hover,
.crm-dashboard-list-row:focus-visible {
    color: var(--brand-dark);
    background: #f8fbfc;
    outline: none;
}
.crm-dashboard-list-row > span:last-child {
    flex: 0 0 auto;
    text-align: right;
}
.crm-overdue-date {
    color: var(--red);
    font-size: 11px;
    font-weight: 700;
}
.crm-dashboard-section.has-warning {
    border-color: #e8cf9d;
}

@media (max-width: 1100px) {
    .crm-dashboard-finance-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .crm-dashboard-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .crm-dashboard-content-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .crm-dashboard-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }
    .crm-dashboard-finance-grid {
        grid-template-columns: 1fr;
    }
    .crm-dashboard-kpi-grid {
        grid-template-columns: 1fr;
    }
    .crm-dashboard-section-head {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }
}

/* ── My Tasks (Việc của tôi) ── */
.crm-my-tasks {
    width: 100%;
    max-width: none;
}
.crm-my-tasks .page-header {
    margin-bottom: 24px;
}
.crm-tasks-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
}
.crm-tasks-empty h3 {
    margin-top: 16px;
    color: var(--ink);
}
.crm-task-section {
    margin-bottom: 28px;
    width: 100%;
}
.crm-task-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.crm-task-section-head > div {
    display: flex;
    align-items: center;
    gap: 8px;
}
.crm-task-section-head h5 {
    margin: 0;
    font-size: 1rem;
}
.crm-task-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr));
    gap: 12px;
    width: 100%;
}
.crm-task-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: box-shadow .15s, border-color .15s;
}
.crm-task-card:hover,
.crm-task-card:focus-visible {
    border-color: var(--accent, #087f95);
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    outline: none;
}
.crm-task-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}
.crm-task-card-top strong {
    font-size: .875rem;
    color: var(--accent, #087f95);
}
.crm-task-card-name {
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.3;
}
.crm-task-card-meta {
    display: flex;
    gap: 16px;
    font-size: .8125rem;
    color: var(--muted);
    margin-bottom: 8px;
}
.crm-task-card-meta i {
    margin-right: 4px;
}
.crm-task-card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
}
.crm-task-card-owners {
    display: flex;
    gap: 16px;
}
@media (max-width: 600px) {
    .crm-task-cards {
        grid-template-columns: 1fr;
    }
}

/* Client-side paged lists inside tabs (frontend/shared/pagination.js). */
.is-paged [hidden] {
    display: none !important;
}

.crm-list-pager {
    margin-top: 12px;
    flex-wrap: wrap;
}

/* Click-to-sort table headers (frontend/shared/table-sort.js). */
[data-sort-ready] {
    cursor: pointer;
    user-select: none;
}

[data-sort-ready]::after {
    content: "⇅";
    margin-left: 4px;
    color: var(--muted);
    font-size: 11px;
    opacity: .55;
}

[data-sort-ready][aria-sort="ascending"]::after {
    content: "▲";
    color: var(--brand);
    opacity: 1;
}

[data-sort-ready][aria-sort="descending"]::after {
    content: "▼";
    color: var(--brand);
    opacity: 1;
}

[data-sort-ready]:hover::after {
    opacity: 1;
}

[data-sort-ready]:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: -2px;
}

/* Row cells are real links to the detail page (shared/row-links.js), so the
   browser's right-click menu can open a record in a new tab or window. The
   link's overlay fills the whole cell, padding included, without changing the
   cell's layout. */
td:has(> .crm-cell-link),
[role="cell"]:has(> .crm-cell-link) {
    position: relative;
}

.crm-cell-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.crm-cell-link::after {
    content: '';
    position: absolute;
    inset: 0;
}

.crm-cell-link:hover,
.crm-cell-link:focus {
    color: inherit;
    text-decoration: none;
}

[role="cell"] > .crm-cell-link {
    display: contents;
}

/* ===== Lead inbox (Meta Lead Ads) ===== */
.crm-lead-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.crm-alert-warning { border-color: #f3dca3; color: #6f4e0c; background: #fffaf0; }
.crm-alert-info { border-color: #bcd7f2; color: #22507d; background: #f4f9ff; }
.crm-alert-success { border-color: #bfe3cf; color: #1f6a43; background: #f3fbf6; }
.crm-lead-modal .crm-alert { margin-bottom: 12px; padding: 10px 12px; border: 1px solid; border-radius: 6px; }
.crm-lead-setup { margin-bottom: 16px; }
.crm-lead-setup code { word-break: break-all; }
.crm-lead-row.is-new td:first-child { box-shadow: inset 3px 0 0 var(--brand, #176b61); }
.crm-lead-time { white-space: nowrap; }
.crm-lead-existing { display: block; color: #22507d; }
.crm-lead-contact { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.crm-lead-contact .button { text-decoration: none; }
.crm-lead-facts { display: grid; grid-template-columns: minmax(110px, 30%) 1fr; gap: 6px 14px; margin: 0 0 18px; padding: 12px 14px; border-radius: 6px; background: var(--canvas, #f5f7f7); }
.crm-lead-facts dt { color: var(--muted, #667); font-weight: 500; }
.crm-lead-facts dd { margin: 0; overflow-wrap: anywhere; }
.crm-lead-form .field { margin-bottom: 12px; }
.crm-lead-form [hidden] { display: none !important; }
.crm-lead-form .field > label { display: block; margin-bottom: 4px; font-weight: 500; }
.crm-lead-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.crm-lead-notes { height: auto; min-height: 76px; resize: vertical; }
.crm-lead-owner { display: flex; align-items: center; gap: 10px; min-height: 38px; }
.crm-lead-convert { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; padding: 10px 12px; border: 1px dashed var(--line, #dde3e3); border-radius: 6px; }
.crm-lead-convert .field-control { width: auto; min-width: 120px; }
.crm-lead-modal .modal-foot { display: flex; justify-content: flex-end; gap: 8px; }
@media (max-width: 640px) {
    .crm-lead-form-grid, .crm-lead-facts { grid-template-columns: 1fr; }
    .crm-lead-facts dt { margin-top: 6px; }
}

/* Opportunity documents tab */
.crm-project-tab__count[hidden] { display: none; }
.crm-doc-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.crm-doc-header h5 { margin: 0; }
.crm-doc-header-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.crm-doc-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.crm-doc-filter {
    display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
    border: 1px solid var(--line); border-radius: 999px; background: var(--paper);
    color: var(--ink); font-size: 13px; cursor: pointer;
}
.crm-doc-filter span { color: var(--muted); font-weight: 700; }
.crm-doc-filter.active { border-color: var(--brand); color: var(--brand-dark); background: var(--brand-pale, var(--canvas)); }
.crm-doc-group { padding: 10px 0; border-top: 1px solid var(--line); }
.crm-doc-group:first-of-type { border-top: 0; }
.crm-doc-group-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.crm-doc-group-head h6 { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 0; font-size: 14px; }
.crm-doc-count { color: var(--muted); font-weight: 600; }
.crm-doc-group-desc { margin: 2px 0 6px; color: var(--muted); font-size: 12px; }
.crm-doc-group .crm-empty-note { margin: 4px 0 0; font-size: 13px; }
.crm-doc-list { display: grid; gap: 8px; margin: 8px 0 0; padding: 0; list-style: none; }
.crm-doc-item {
    display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; align-items: start;
    padding: 10px; border: 1px solid var(--line); border-left-width: 3px; border-radius: 6px; background: var(--paper);
}
.crm-doc-item.is-pending { border-left-color: var(--amber, #d89414); }
.crm-doc-item.is-valid { border-left-color: #2e9b63; }
.crm-doc-item.is-rejected { border-left-color: var(--red, #c94343); }
.crm-doc-item { grid-template-columns: 38px minmax(0, 1fr) auto; }
.crm-doc-kind {
    display: inline-grid; place-items: center; width: 38px; height: 22px; margin-top: 1px;
    border-radius: 4px; color: #fff; background: #7a8494; font-size: 10px; font-weight: 800; letter-spacing: 0.03em;
}
.crm-doc-kind.is-pdf { background: #c94343; }
.crm-doc-kind.is-img { background: #2f7fb5; }
.crm-doc-kind.is-doc { background: #2b5797; }
.crm-doc-kind.is-xls { background: #217346; }
.crm-doc-actions .btn svg { display: block; }
.crm-doc-body { display: grid; gap: 3px; min-width: 0; font-size: 13px; }
.crm-doc-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.crm-doc-title .btn-link { max-width: 100%; overflow-wrap: anywhere; text-align: left; font-weight: 600; }
.crm-doc-meta, .crm-doc-reviewed { color: var(--muted); }
.crm-doc-note { color: var(--ink); white-space: pre-line; }
.crm-doc-reject {
    display: grid; gap: 2px; padding: 6px 8px; border-radius: 4px;
    color: #8f2f2f; background: #fbe6e6; white-space: pre-line;
}
.crm-doc-reject small { color: #a35b5b; }
.crm-doc-history summary { color: var(--muted); font-size: 12px; cursor: pointer; }
.crm-doc-history ol { margin: 4px 0 0; padding-left: 18px; color: var(--muted); font-size: 12px; }
.crm-doc-history-reason { color: #8f2f2f; }
.crm-doc-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.crm-doc-type-active { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.crm-prep-config-item.is-inactive { opacity: 0.65; }
@media (max-width: 640px) {
    .crm-doc-item { grid-template-columns: 38px minmax(0, 1fr); }
    .crm-doc-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

/* Hourly tiered rental */
.li-cell--hours { width: 90px; }
.li-cell--days { width: 75px; }
.crm-hourly-preview table { width: auto; min-width: 320px; max-width: 100%; margin-top: 8px; }
.crm-hourly-preview .is-money { text-align: right; }
