/* Four-ball swapping loader — lightweight global overlay */
.crm-loader-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.crm-loader-overlay.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.crm-loader-box {
    background: rgba(255, 255, 255, 0.96);
    border-radius: 16px;
    padding: 28px 36px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    text-align: center;
    min-width: 140px;
}

.crm-loader-label {
    margin-top: 14px;
    font-size: 0.82rem;
    color: #64748b;
    font-weight: 500;
}

.crm-four-ball {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 36px;
}

.crm-four-ball span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    animation: crmBallSwap 1.1s ease-in-out infinite;
}

.crm-four-ball span:nth-child(1) { background: var(--brand-primary, #428bca); animation-delay: 0s; }
.crm-four-ball span:nth-child(2) { background: #1f2937; animation-delay: 0.15s; }
.crm-four-ball span:nth-child(3) { background: #059669; animation-delay: 0.3s; }
.crm-four-ball span:nth-child(4) { background: #f59e0b; animation-delay: 0.45s; }

@keyframes crmBallSwap {
    0%, 100% { transform: translateY(0) scale(1); opacity: 0.55; }
    50% { transform: translateY(-14px) scale(1.15); opacity: 1; }
}

/* Skeleton shimmer */
.crm-skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: crmShimmer 1.2s infinite;
    border-radius: 8px;
}

@keyframes crmShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.crm-skeleton-line { height: 14px; margin-bottom: 10px; }
.crm-skeleton-line.w60 { width: 60%; }
.crm-skeleton-line.w80 { width: 80%; }
.crm-skeleton-line.w40 { width: 40%; }

/* Lead modal tabs */
.lm-modal-container.lm-tabbed {
    flex-direction: column;
    max-width: 920px;
    width: 96vw;
}

.lm-modal-header-bar {
    padding: 16px 20px 0;
    border-bottom: 1px solid #eaeaea;
    background: #fff;
    flex-shrink: 0;
}

.lm-modal-header-bar h5 {
    margin: 0 0 4px;
    font-size: 1.15rem;
    font-weight: 700;
}

.lm-modal-header-meta {
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 10px;
}

.lm-tab-bar {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding-bottom: 0;
    scrollbar-width: none;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 2;
}

.lm-tab-bar::-webkit-scrollbar { display: none; }

.lm-tab-btn {
    border: none;
    background: transparent;
    padding: 10px 14px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #64748b;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.lm-tab-btn:hover { color: var(--brand-primary, #428bca); }
.lm-tab-btn.active {
    color: var(--brand-primary, #428bca);
    border-bottom-color: var(--brand-primary, #428bca);
}

.lm-tab-panels {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px 20px;
    background: #f8fafc;
}

.lm-tab-panel { display: none; }
.lm-tab-panel.active { display: block; }

.lm-tab-panel .lm-panel-inner {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    border: 1px solid #e2e8f0;
}

.lm-sticky-actions {
    position: sticky;
    bottom: 0;
    background: linear-gradient(180deg, transparent, #f8fafc 30%);
    padding-top: 12px;
    margin-top: 12px;
}

@media (max-width: 768px) {
    .lm-modal-container.lm-tabbed { width: 100vw; max-width: 100vw; height: 100vh; border-radius: 0; }
}

/* Lead overview tab */
.lm-overview-wrap {
    padding: 0;
}

.lm-ov-hero {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 16px;
    padding: 20px;
    border-radius: 14px;
    background: var(--brand-sidebar, #428bca);
    color: #fff;
    margin-bottom: 16px;
    box-shadow: 0 10px 32px rgba(66, 139, 202, 0.2);
}

.lm-ov-hero-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.lm-ov-avatar {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 800;
    flex-shrink: 0;
}

.lm-ov-name {
    margin: 0 0 4px;
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.2;
}

.lm-ov-company {
    font-size: 0.85rem;
    opacity: 0.92;
    margin-bottom: 8px;
}

.lm-ov-status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.22);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.lm-ov-hero-meta {
    display: flex;
    gap: 20px;
    align-items: flex-end;
    text-align: right;
}

.lm-ov-hero-meta small {
    display: block;
    opacity: 0.8;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.lm-ov-hero-meta strong {
    font-size: 0.9rem;
}

.lm-ov-contacts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}

.lm-ov-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 50px;
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #334155;
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.lm-ov-chip:hover {
    border-color: var(--brand-primary, #428bca);
    color: var(--brand-primary, #428bca);
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.12);
}

.lm-ov-chip--wa:hover {
    border-color: #25d366;
    color: #128c41;
}

.lm-ov-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.lm-ov-section-title i {
    color: var(--brand-primary, #428bca);
}

.lm-ov-pipeline {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 20px;
    padding: 14px 12px;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    overflow-x: auto;
}

.lm-ov-pipe-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 52px;
    font-size: 0.65rem;
    font-weight: 600;
    color: #94a3b8;
    text-align: center;
}

.lm-ov-pipe-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f1f5f9;
    border: 2px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.lm-ov-pipe-step.done .lm-ov-pipe-dot {
    background: #ecfdf5;
    border-color: #34d399;
    color: #059669;
}

.lm-ov-pipe-step.active .lm-ov-pipe-dot {
    background: #f3f4f6;
    border-color: var(--brand-primary, #428bca);
    color: var(--brand-primary, #428bca);
    box-shadow: 0 0 0 4px rgba(67, 97, 238, 0.15);
}

.lm-ov-pipe-step.done span:last-child,
.lm-ov-pipe-step.active span:last-child {
    color: #334155;
}

.lm-ov-pipe-line {
    flex: 1;
    height: 2px;
    min-width: 12px;
    background: #e2e8f0;
    margin-bottom: 18px;
}

.lm-ov-pipe-line.done {
    background: linear-gradient(90deg, #34d399, var(--brand-primary, #428bca));
}

.lm-ov-kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.lm-ov-kpi {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    transition: box-shadow 0.2s;
}

.lm-ov-kpi:hover {
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.06);
}

.lm-ov-kpi span {
    display: block;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    margin-bottom: 2px;
}

.lm-ov-kpi strong {
    font-size: 0.95rem;
    color: #1e293b;
    line-height: 1.3;
}

.lm-ov-kpi-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.95rem;
}

.lm-ov-kpi--customer .lm-ov-kpi-icon { background: #f3f4f6; color: var(--brand-primary, #428bca); }
.lm-ov-kpi--out .lm-ov-kpi-icon { background: #fff7ed; color: #ea580c; }
.lm-ov-kpi--in .lm-ov-kpi-icon { background: #ecfdf5; color: #059669; }
.lm-ov-kpi--docs .lm-ov-kpi-icon { background: #f5f3ff; color: #7c3aed; }

.lm-ov-actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    margin-bottom: 16px;
}

.lm-ov-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 8px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #475569;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.lm-ov-action i {
    font-size: 1.15rem;
    color: #64748b;
}

.lm-ov-action:hover {
    border-color: var(--brand-primary, #428bca);
    color: var(--brand-primary, #428bca);
    background: #f8faff;
    transform: translateY(-1px);
}

.lm-ov-action:hover i {
    color: var(--brand-primary, #428bca);
}

.lm-ov-action--primary {
    background: var(--brand-sidebar, #428bca);
    border-color: var(--brand-sidebar, #428bca);
    color: #fff;
}

.lm-ov-action--primary i {
    color: #fff;
}

.lm-ov-action--primary:hover {
    color: #fff;
    box-shadow: 0 8px 24px rgba(66, 139, 202, 0.3);
}

.lm-ov-note {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    background: #fff;
    border-radius: 12px;
    border-left: 4px solid var(--brand-primary, #428bca);
    border: 1px solid #e2e8f0;
    border-left-width: 4px;
}

.lm-ov-note i {
    color: #94a3b8;
    margin-top: 2px;
}

.lm-ov-note p {
    margin: 0;
    font-size: 0.88rem;
    color: #475569;
    line-height: 1.5;
}

@media (max-width: 480px) {
    .lm-ov-kpi-grid { grid-template-columns: 1fr; }
    .lm-ov-hero-meta { width: 100%; justify-content: flex-start; text-align: left; }
}
