.leads-workspace {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.25rem;
    border: 1px solid var(--glass-border);
    background:
        radial-gradient(circle at top right, rgba(59, 130, 196, 0.14), transparent 32%),
        radial-gradient(circle at bottom left, rgba(45, 138, 110, 0.12), transparent 30%),
        var(--glass-bg);
}

.leads-stage-toolbar,
.leads-followup-banner {
    border: 1px solid var(--glass-border);
    background: rgba(12, 18, 20, 0.48);
    box-shadow: var(--shadow-sm);
}

.leads-module-switcher {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.1rem;
    border-radius: var(--radius-lg);
}

.leads-switcher-kicker {
    display: inline-block;
    margin-bottom: 0.35rem;
    color: var(--info);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.leads-module-pills,
.leads-stage-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.lead-module-pill,
.lead-stage-pill {
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.lead-module-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 42px;
    padding: 0.7rem 0.95rem;
    border-radius: 999px;
    font-size: 0.92rem;
    font-weight: 600;
}

.lead-module-pill:hover,
.lead-stage-pill:hover {
    transform: translateY(-1px);
    border-color: rgba(45, 138, 110, 0.35);
    background: rgba(45, 138, 110, 0.12);
}

.lead-module-pill.active {
    border-color: rgba(45, 138, 110, 0.4);
    background: linear-gradient(135deg, rgba(45, 138, 110, 0.2), rgba(59, 130, 196, 0.14));
    box-shadow: 0 10px 24px rgba(45, 138, 110, 0.16);
}

.leads-followup-banner {
    display: grid;
    grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
    gap: 1rem;
    padding: 1rem 1.1rem;
    border-radius: var(--radius-lg);
}

.leads-followup-banner.hidden {
    display: none !important;
}

.leads-followup-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.lead-followup-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.85rem 0.95rem;
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
}

.lead-followup-name {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.2rem;
}

.lead-followup-note {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.lead-followup-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.leads-stage-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.1rem;
    border-radius: var(--radius-lg);
}

.lead-stage-pill {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.85rem;
    min-width: 180px;
    padding: 0.85rem 1rem;
    border-radius: 18px;
    text-align: left;
}

.lead-stage-pill-copy {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.lead-stage-pill-copy strong {
    font-size: 0.95rem;
}

.lead-stage-pill-copy small {
    color: var(--text-muted);
    font-size: 0.76rem;
}

.lead-stage-pill-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 0.6rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 0.88rem;
    font-weight: 700;
}

.lead-stage-pill.active {
    border-color: rgba(59, 130, 196, 0.4);
    background: linear-gradient(135deg, rgba(59, 130, 196, 0.16), rgba(45, 138, 110, 0.16));
    box-shadow: 0 12px 26px rgba(2, 132, 199, 0.16);
}

.lead-stage-pill.active .lead-stage-pill-count {
    background: rgba(255, 255, 255, 0.16);
}

.leads-stage-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.2rem;
    color: var(--text-muted);
    font-size: 0.84rem;
    text-align: right;
}

.leads-list-shell {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    background: rgba(12, 18, 20, 0.34);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

/* Tabla de prospectos: cada prospecto es una fila fácil de manejar */
.leads-table {
    --bs-table-bg: transparent;
    --bs-table-accent-bg: transparent;
    --bs-table-color: var(--text);
    color: var(--text);
    margin-bottom: 0;
    min-width: 920px;
}

.leads-table > thead > tr > th {
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    border-bottom: 1px solid var(--glass-border) !important;
    white-space: nowrap;
    padding: 0.95rem 1.1rem;
}

.leads-table > thead > tr > th:last-child {
    text-align: right;
}

.leads-table tbody td {
    vertical-align: middle;
    padding: 0.95rem 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.leads-table tbody tr:last-child td {
    border-bottom: none;
}

/* Ahora cada prospecto es una fila <tr> estilada vía .leads-table */
.lead-row {
    cursor: pointer;
}

.lead-row-main {
    min-width: 0;
}

.lead-cell-label {
    display: none;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 0.28rem;
}

.lead-row-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 0.25rem;
}

.lead-row-title strong {
    font-size: 1rem;
}

.lead-row-subtitle,
.lead-row-note,
.lead-row-muted {
    color: var(--text-muted);
    font-size: 0.84rem;
}

.lead-row-note {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.lead-contact-stack,
.lead-stage-stack,
.lead-date-stack,
.lead-amount-stack {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.lead-contact-line {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
    color: var(--text);
    font-size: 0.88rem;
}

.lead-contact-line span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lead-stage-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: flex-start;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.lead-stage-badge.stage-nuevo {
    color: #7dd3fc;
    background: rgba(2, 132, 199, 0.14);
    border: 1px solid rgba(2, 132, 199, 0.22);
}

.lead-stage-badge.stage-en_seguimiento {
    color: #fbbf24;
    background: rgba(217, 119, 6, 0.14);
    border: 1px solid rgba(217, 119, 6, 0.24);
}

.lead-stage-badge.stage-prospecto {
    color: #86efac;
    background: rgba(22, 163, 74, 0.15);
    border: 1px solid rgba(22, 163, 74, 0.22);
}

.lead-stage-select {
    min-height: 36px;
    border-radius: 10px;
    font-size: 0.82rem;
}

.lead-amount-main {
    font-size: 0.98rem;
    font-weight: 700;
}

.lead-amount-main.pending {
    color: #fbbf24;
}

.lead-amount-main.collected {
    color: #86efac;
}

.lead-row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.lead-row-actions .btn {
    white-space: nowrap;
}

.lead-empty-state {
    padding: 2.4rem 1.25rem;
    text-align: center;
    border: 1px dashed rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.03);
}

.lead-empty-state i {
    display: inline-flex;
    margin-bottom: 0.85rem;
    font-size: 2.2rem;
    color: var(--text-muted);
}

[data-theme="light"] .leads-stage-toolbar,
[data-theme="light"] .leads-followup-banner {
    background: rgba(255, 255, 255, 0.74);
}

[data-theme="light"] .lead-followup-item,
[data-theme="light"] .lead-empty-state {
    background: rgba(241, 245, 249, 0.9);
}

[data-theme="light"] .lead-module-pill,
[data-theme="light"] .lead-stage-pill {
    border-color: rgba(15, 23, 42, 0.08);
    background: rgba(255, 255, 255, 0.88);
    color: var(--text);
}

[data-theme="light"] .leads-list-shell {
    background: rgba(255, 255, 255, 0.60);
    border-color: rgba(15, 23, 42, 0.10);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
}
[data-theme="light"] .leads-table tbody td {
    border-bottom-color: rgba(15, 23, 42, 0.06);
}
[data-theme="light"] .leads-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.85) !important;
}

@media (max-width: 1199.98px) {
    .leads-stage-toolbar,
    .leads-followup-banner {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }

    .leads-stage-meta {
        align-items: flex-start;
        text-align: left;
    }
}

@media (max-width: 767.98px) {
    .leads-workspace {
        padding: 0.95rem;
    }

    .lead-stage-pill {
        width: 100%;
    }

    .lead-contact-line span {
        white-space: normal;
    }

    .lead-row-actions {
        width: 100%;
    }

    .lead-row-actions .btn {
        flex: 1 1 auto;
        justify-content: center;
    }

.lead-followup-item {
        grid-template-columns: 1fr;
    }
}

/* The selected prospect stays visible beside the operational list. */
.leads-record-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.75fr);
    gap: 1rem;
    align-items: start;
}

.leads-record-layout .leads-list-shell {
    min-width: 0;
}

.lead-detail-card {
    position: sticky;
    top: 1rem;
    min-width: 0;
    max-height: min(70vh, 760px);
    overflow-y: auto;
    padding: 1.2rem;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    background: var(--glass-bg);
    box-shadow: var(--shadow-sm);
}

.lead-row.selected > td {
    background: rgba(59, 130, 196, 0.14) !important;
    border-top: 1px solid rgba(59, 130, 196, 0.35);
    border-bottom-color: rgba(59, 130, 196, 0.35);
}

.lead-detail-contact {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 1rem 0;
}

.lead-detail-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
    padding: 0.8rem 0;
    border-top: 1px solid var(--glass-border);
    border-bottom: 1px solid var(--glass-border);
}

.lead-detail-stats div,
.lead-detail-fields div {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.lead-detail-stats span,
.lead-detail-fields span,
.lead-detail-notes > span {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.lead-detail-stats strong {
    font-size: 0.9rem;
}

.lead-detail-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
    padding: 1rem 0;
}

.lead-detail-fields strong {
    overflow-wrap: anywhere;
    font-size: 0.88rem;
}

.lead-detail-fields small {
    color: var(--text-muted);
    font-size: 0.76rem;
}

.lead-detail-notes {
    padding-top: 0.85rem;
    border-top: 1px solid var(--glass-border);
}

.lead-detail-notes p {
    margin: 0.45rem 0 0;
    color: var(--text);
    font-size: 0.88rem;
    line-height: 1.55;
    white-space: pre-wrap;
}

@media (max-width: 991.98px) {
    .leads-record-layout {
        grid-template-columns: 1fr;
    }

    .lead-detail-card {
        position: static;
        max-height: none;
    }
}

@media (max-width: 575.98px) {
    .lead-detail-header {
        flex-direction: column;
    }

    .lead-detail-stats,
    .lead-detail-fields {
        grid-template-columns: 1fr;
    }
}
