/* ============================================================================
   CRM Wiener — Views: Kanban, Modal, Pivot, Timeline, Contacts, Prospects,
                       Geo, Search, Pickers, Sale Orders
   ============================================================================ */

/* ============================================================================
   Validation tooltip
   ============================================================================ */
.cf-validation-tooltip {
    position: fixed;
    z-index: 9999;
    background: #f97316;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    padding: 5px 10px 5px 8px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 7px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.18);
    pointer-events: none;
    white-space: nowrap;
}
.cf-validation-tooltip::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 12px;
    border: 5px solid transparent;
    border-bottom-color: #f97316;
    border-top: 0;
}
.cf-val-tip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: rgba(255,255,255,0.25);
    border-radius: 50%;
    font-size: 10px;
    font-weight: 800;
    flex-shrink: 0;
    line-height: 1;
}

/* ============================================================================
   Login
   ============================================================================ */

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: var(--gray-100);
}

.login-card {
    background: var(--white);
    padding: 56px 48px;
    width: 100%;
    max-width: 400px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border-top: 3px solid var(--crimson);
    animation: loginFadeUp 0.18s ease-out both;
    position: relative;
    z-index: 1;
}

@keyframes loginFadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.login-brand {
    text-align: center;
    margin-bottom: 40px;
}

.login-brand-logo {
    display: block;
    margin: 0 auto;
    width: 160px;
    height: auto;
}

.login-brand-tagline {
    display: block;
    font-size: 11px;
    color: var(--gray-500);
    letter-spacing: 0.8px;
    text-transform: uppercase;
    margin-top: 10px;
    font-weight: 400;
}

.login-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
    text-align: left;
    margin-bottom: 4px;
}

.login-subtitle {
    text-align: left;
    color: var(--gray-500);
    margin-bottom: 32px;
    font-size: 13px;
}

.login-note {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-200);
    text-align: center;
    color: var(--gray-500);
    font-size: 12px;
}

.login-form { margin-top: 0; }

.login-form .btn-primary {
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    padding: 13px 16px;
    letter-spacing: 0.2px;
}

.login-form .btn-primary:hover:not(:disabled) {
    transform: none;
    background-color: var(--crimson-dark);
}

@media (max-width: 480px) {
    .login-card {
        padding: 40px 28px;
        border-radius: 0;
        border-top: none;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
}

/* ============================================================================
   Kanban Board
   ============================================================================ */

.kanban-container {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 16px;
}

.kanban-board {
    display: flex;
    gap: 8px;
    padding: 8px 0;
    align-items: flex-start;
    width: 100%;
}

/* Phase group wrappers — solo para agrupación por etapa */
.kanban-board--phased {
    gap: 14px;
}

.kanban-phase-group {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 4px;
}

.kanban-phase-columns {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.kanban-phase-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    padding: 3px 6px 4px;
    border-radius: 3px;
    border-top: 2px solid transparent;
    white-space: nowrap;
}

.kanban-phase-group--early .kanban-phase-label {
    color: #5b7dc8;
    background: rgba(91, 125, 200, 0.08);
    border-top-color: rgba(91, 125, 200, 0.35);
}
.kanban-phase-group--mid .kanban-phase-label {
    color: #b5790a;
    background: rgba(181, 121, 10, 0.07);
    border-top-color: rgba(181, 121, 10, 0.35);
}
.kanban-phase-group--late .kanban-phase-label {
    color: #5b7272;
    background: rgba(91, 114, 114, 0.07);
    border-top-color: rgba(91, 114, 114, 0.35);
}

.kanban-column {
    flex: 1 1 0;
    min-width: 200px;
    background: var(--white);
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.kanban-column-header {
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--gray-200);
}

.kanban-column-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.kanban-column-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kanban-column-amount {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
}

.kanban-column-count {
    font-size: 11px;
    color: var(--crimson);
    background: var(--crimson-light);
    padding: 4px 10px;
    font-weight: 600;
    border-radius: var(--radius-full);
}

.kanban-column-progress {
    height: 2px;
    background: var(--gray-300);
    margin-top: 12px;
    overflow: hidden;
}

.kanban-column-progress-bar {
    height: 100%;
    background: var(--crimson);
}

.kanban-column-cards {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-height: 60px;
}

/* Kanban card (compact) */
.kanban-card {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--gray-50);
    padding: 8px 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    border-radius: 5px;
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.kanban-card:hover {
    border-color: var(--crimson);
    transform: scale(1.015);
    box-shadow: var(--shadow-md);
}

.kanban-card-opportunity-name {
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.kanban-card-title {
    font-size: 0.68rem;
    font-weight: 400;
    color: var(--gray-500);
    line-height: 1.25;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kanban-card-company {
    font-size: 0.72rem;
    color: var(--gray-500);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kanban-card-budget {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--crimson);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kanban-card-so-badge {
    font-size: 0.68rem;
    color: var(--gray-600);
    background: var(--gray-100);
    border-radius: 4px;
    padding: 2px 6px;
    margin: 0;
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    gap: 4px;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kanban-card-so-contract {
    font-size: 0.6rem;
    color: #4a7c59;
    background: #f0f7f2;
    border: 1px solid #b8d9c3;
    border-radius: 3px;
    padding: 0 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    flex-shrink: 0;
}

.prospect-so-total {
    font-size: 1rem;
    font-weight: 700;
    color: var(--crimson);
}

.kanban-card-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 2px;
}

.kanban-card-type {
    font-size: 10px;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    gap: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.kanban-card-type-dot {
    width: 6px;
    height: 6px;
    background: var(--crimson);
    border-radius: var(--radius-full);
}

.kanban-card-type-text {
    text-transform: uppercase;
    font-size: 0.68rem;
}

.kanban-card-label {
    font-size: 0.65rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 1px 5px;
}

.kanban-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid var(--gray-300);
    gap: 4px;
}

.kanban-card-rating {
    display: flex;
    align-items: center;
    gap: 1px;
}

.kanban-card-star { font-size: 10px; color: var(--crimson); }
.kanban-card-star.empty { color: var(--gray-300); }
.kanban-card-time { font-size: 0.62rem; color: var(--gray-500); text-transform: uppercase; }

.kanban-card-badge {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--white);
    background: var(--crimson);
    border-radius: var(--radius-full);
}

.kanban-card-badge.green   { background: var(--success); }
.kanban-card-badge.purple  { background: var(--purple); }
.kanban-card-badge.orange  { background: var(--warning); }
.kanban-card-badge.crimson { background: var(--crimson); }
.kanban-card-badge.dark-red { background: var(--crimson-dark); }
.kanban-card-badge.blue    { background: var(--info); }

.kanban-card-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: none;
    gap: 3px;
    z-index: 5;
}

.kanban-card:hover .kanban-card-actions { display: flex; }

.kanban-card-action-btn {
    width: 26px;
    height: 26px;
    border: none;
    background: var(--white);
    color: var(--gray-700);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.15s ease;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-300);
    padding: 1px 4px;
}

.kanban-card-action-btn:hover {
    background: var(--crimson);
    color: var(--white);
    border-color: var(--crimson);
}

/* Inactive kanban card */
.kanban-card--inactive {
    background: #fdf6ec;
    border-color: #e8d5b0;
    opacity: 0.82;
}

.kanban-card--inactive:hover {
    border-color: #c9a96e;
    background: #fdf0df;
}

.kanban-card-inactive-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #7a5a1e;
    background: #f5dfa0;
    border-radius: 4px;
    padding: 2px 6px;
    align-self: flex-start;
}

.kanban-card-incomplete-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #7a4a00;
    background: #ffe0b2;
    border-radius: 4px;
    padding: 2px 6px;
    align-self: flex-start;
}

.kanban-card-lost-ribbon {
    position: absolute;
    top: 10px;
    right: -22px;
    width: 80px;
    text-align: center;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #fff;
    background: var(--crimson);
    padding: 3px 0;
    transform: rotate(45deg);
    pointer-events: none;
    z-index: 4;
}

#modal-incomplete-warning {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 20px;
    background: #fff8f0;
    border-left: 3px solid #fb923c;
    font-size: 12px;
    color: #7a4a00;
    flex-shrink: 0;
}

#modal-incomplete-warning a {
    color: #7a4a00;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

#modal-incomplete-warning a:hover {
    color: #92400e;
}

/* ============================================================================
   Modal
   ============================================================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    max-width: 1600px;
    width: 98%;
    max-height: 96vh;
    display: flex;
    flex-direction: column;
    z-index: 2001;
    animation: modalSlideIn 0.3s ease-out;
}

.modal-content-small {
    max-width: 600px;
    width: 90%;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 14px;
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0;
}

.modal-header-meta-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 2px;
    flex-wrap: wrap;
}

.modal-header-meta-sep { color: var(--gray-300); font-size: 12px; }
.modal-header-meta-item { font-size: 12px; color: var(--gray-500); }

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--gray-500);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.modal-body {
    padding: 10px;
    overflow-y: auto;
    flex: 1;
    max-height: calc(96vh - 100px);
}

.modal-body--contact { padding: 0; }

.modal-body::-webkit-scrollbar { width: 6px; }
.modal-body::-webkit-scrollbar-track { background: var(--gray-100); }
.modal-body::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
.modal-body::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 10px 16px;
    border-top: 1px solid var(--gray-200);
    flex-shrink: 0;
    background: var(--gray-50);
}

/* Modal loading / save overlays */
.modal-loading {
    text-align: center;
    padding: 48px;
    color: var(--gray-500);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.modal-loading p {
    margin-top: 16px;
    font-size: 14px;
    color: var(--gray-600);
}

.modal-company-contact-loading,
.modal-save-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 10;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.modal-save-overlay { background: rgba(255, 255, 255, 0.85); }

.modal-company-contact-loading p,
.modal-save-spinner-wrap p {
    margin: 0;
    font-size: 14px;
    color: var(--gray-600);
}

.modal-save-spinner-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--gray-700);
    font-size: 14px;
}

/* Modal detail sections */
.modal-details {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.modal-detail-section {
    padding-top: 20px;
    border-top: 1px solid var(--gray-200);
}

.modal-detail-section:first-child {
    border-top: none;
    padding-top: 0;
}

.modal-section-title {
    font-size: 10px;
    font-weight: 600;
    color: var(--crimson);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.modal-detail-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 16px;
}

.modal-detail-row:last-child { margin-bottom: 0; }

.modal-detail-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.modal-detail-item.full-width { grid-column: 1 / -1; }

.modal-detail-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.modal-detail-value {
    font-size: 14px;
    color: var(--gray-900);
    line-height: 1.5;
}

/* Modal form sections */
.modal-form-section {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    margin-bottom: 0;
    overflow: hidden;
}

.modal-section-header {
    background: var(--white);
    padding: 4px 10px;
    border-bottom: 1px solid var(--gray-200);
}

.modal-form-content { padding: 8px 10px; }
.modal-form-content .form-row { margin-bottom: 6px; }
.modal-form-content .form-row:last-child { margin-bottom: 0; }
.modal-form-content .form-group { margin-bottom: 0; }

.modal-form-content .form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
}

.modal-form-content .form-group.full-width { grid-column: 1 / -1; }

.modal-form-content .form-group label {
    font-size: 11px;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.modal-form-content .form-input,
.modal-form-content .form-select,
.modal-form-content .form-textarea {
    background: var(--white);
    border: 1.5px solid var(--gray-300);
    padding: 6px 10px;
    font-size: 13px;
}

.modal-form-content .form-input:focus,
.modal-form-content .form-select:focus,
.modal-form-content .form-textarea:focus {
    border-color: var(--crimson);
    box-shadow: 0 0 0 3px var(--crimson-light);
}

.modal-form-content small {
    display: block;
    margin-top: 6px;
    color: var(--gray-500);
    font-size: 11px;
}

.modal-form-section h4.modal-section-title {
    font-size: 14px;
    margin-bottom: 10px;
}

/* Modal relation management */
.modal-relation-add {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
    margin-bottom: 12px;
}

.modal-relation-add .form-select,
.modal-relation-add .form-input { min-width: 120px; }

.modal-relation-list { margin-top: 8px; }

.modal-relation-list .empty-state {
    padding: 12px;
    color: var(--gray-500);
    font-size: 13px;
}

/* Prospect form override */
#modal-prospect-form { display: block; }
#modal-prospect-form > .modal-form-section { margin-bottom: 0; }
#modal-prospect-form > .modal-form-section.full-width-section { grid-column: 1 / -1; }

/* Modal tabs (v5) */
.modal-tabs-bar {
    display: flex;
    justify-content: center;
    border-bottom: 2px solid var(--gray-200);
    padding: 0 14px;
    flex-shrink: 0;
    background: var(--gray-50);
    gap: 2px;
    margin: -10px -10px 0;
}

.modal-tab-btn {
    padding: 10px 18px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--gray-700);
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    white-space: nowrap;
    border-radius: 4px 4px 0 0;
}

.modal-tab-btn:hover {
    color: var(--crimson);
    background: rgba(220, 20, 60, 0.04);
}

.modal-tab-btn.active {
    color: var(--crimson);
    border-bottom-color: var(--crimson);
    font-weight: 600;
}

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

.modal-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--gray-200);
    color: var(--gray-600);
    border-radius: 9px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 5px;
    line-height: 1;
}

.modal-tab-btn.active .modal-tab-badge {
    background: var(--crimson-light);
    color: var(--crimson);
}

/* ============================================================================
   Stage Pipeline
   ============================================================================ */

.stage-pipeline-wrap {
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    padding: 5px 16px;
    overflow-x: auto;
    flex-shrink: 0;
}

.stage-pipeline {
    display: flex;
    align-items: stretch;
    width: 100%;
    gap: 6px;
}

.stage-step {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-600);
    background: var(--white);
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
    flex: 1;
    text-align: center;
    line-height: 1.3;
    min-width: 0;
}

.stage-step:hover:not(.stage-step--active):not(.stage-step--done):not(.stage-step--disabled) {
    background: var(--crimson-light);
    color: var(--crimson);
    border-color: var(--crimson);
    z-index: 1;
}

.stage-step--active {
    background: var(--crimson);
    border-color: var(--crimson);
    color: var(--white);
    font-weight: 700;
    z-index: 2;
    cursor: default;
    box-shadow: 0 2px 8px rgba(220, 20, 60, 0.25);
}

.stage-step--done {
    background: var(--crimson-light);
    color: var(--crimson);
    border-color: var(--crimson);
    font-weight: 500;
    cursor: default;
}

.stage-step--danger:hover {
    background: var(--crimson);
    color: var(--white);
    border-color: var(--crimson);
    z-index: 1;
}

.stage-step--disabled {
    color: var(--gray-400);
    background: var(--gray-50);
    border-color: var(--gray-200);
    cursor: not-allowed !important;
    opacity: 0.7;
}

.stage-step--disabled:hover {
    background: var(--gray-50);
    color: var(--gray-400);
    border-color: var(--gray-200);
    z-index: auto;
    box-shadow: none;
}

.stage-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    border: 1.5px solid currentColor;
    flex-shrink: 0;
    line-height: 1;
}

.stage-step--active .stage-step-num {
    background: rgba(255, 255, 255, 0.25);
    border-color: var(--white);
    color: var(--white);
}

/* Tooltip para botones de pipeline deshabilitados */
.stage-action-tooltip-wrap {
    position: relative;
    display: flex;
    flex: 1;
    cursor: not-allowed;
}

.stage-action-tooltip-wrap > button {
    width: 100%;
}

.stage-action-tooltip-wrap::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 7px);
    right: 0;
    background: var(--gray-800);
    color: #fff;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    white-space: normal;
    max-width: 260px;
    z-index: 1000;
    pointer-events: none;
    line-height: 1.4;
    text-align: right;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s;
}

.stage-action-tooltip-wrap:hover::after {
    opacity: 1;
    visibility: visible;
}

.stage-action-tooltip-wrap::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 1px);
    right: 14px;
    border: 5px solid transparent;
    border-top-color: var(--gray-800);
    z-index: 1001;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s;
}

.stage-action-tooltip-wrap:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Ícono de ayuda con tooltip — formulario de usuario, etc. */
.field-help {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    margin-left: 5px;
    border-radius: 50%;
    background: var(--gray-200, #e5e7eb);
    color: var(--gray-600, #6b7280);
    font-size: 10px;
    font-weight: 700;
    font-style: normal;
    text-transform: none;
    letter-spacing: normal;
    line-height: 1;
    cursor: help;
    position: relative;
    vertical-align: middle;
}
.field-help:hover {
    background: var(--crimson, #DC143C);
    color: #fff;
}
.field-help::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: var(--gray-800, #1f2937);
    color: #fff;
    padding: 7px 11px;
    border-radius: var(--radius-sm, 6px);
    font-size: 12px;
    font-weight: 400;
    white-space: normal;
    width: 240px;
    z-index: 1000;
    pointer-events: none;
    line-height: 1.4;
    text-align: left;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s;
}
.field-help::before {
    content: '';
    position: absolute;
    top: calc(100% + 2px);
    left: 4px;
    border: 5px solid transparent;
    border-bottom-color: var(--gray-800, #1f2937);
    z-index: 1001;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s;
}
.field-help:hover::after,
.field-help:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Tarjeta de formulario deshabilitada (ej. "Países visibles" para rol Supervisor) */
.form-card--disabled {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
}

/* Banner de impersonación */
.impersonate-banner {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    background: #fef3c7;
    color: #92400e;
    border-bottom: 1px solid #fcd34d;
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 500;
}
.impersonate-banner strong {
    font-weight: 700;
}
.impersonate-banner__stop {
    background: #92400e;
    color: #fff;
    border: none;
    border-radius: var(--radius-sm, 6px);
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.impersonate-banner__stop:hover {
    background: #78350f;
}

/* Disabled Presupuestos tab */
.modal-tab-btn--disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.stage-tab-disabled-wrap {
    position: relative;
    display: inline-block;
}

.stage-tab-disabled-wrap::after {
    content: attr(title);
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-800);
    color: #fff;
    padding: 4px 9px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s;
}

.stage-tab-disabled-wrap:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Stage change modal */
.change-stage-subtitle {
    font-size: 14px;
    color: var(--gray-600);
    margin-bottom: 24px;
    text-align: center;
}

.stages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 8px;
}

.stage-card {
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    overflow: hidden;
}

.stage-card:hover {
    border-color: var(--crimson);
    background: var(--crimson-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 20, 60, 0.15);
}

.stage-card-selected {
    border-color: var(--crimson);
    background: var(--crimson-light);
    box-shadow: 0 4px 12px rgba(220, 20, 60, 0.2);
}

.stage-card-disabled { opacity: 0.5; pointer-events: none; }

.stage-card-spinner {
    width: 16px;
    height: 16px;
    border-width: 2px;
    margin-left: 8px;
    flex-shrink: 0;
}

.stage-card-current {
    border-color: var(--crimson);
    background: linear-gradient(135deg, var(--crimson-light) 0%, var(--white) 100%);
}

.stage-card-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--crimson);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.stage-card:hover .stage-card-icon {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(220, 20, 60, 0.3);
}

.stage-card-current .stage-card-icon {
    background: var(--crimson);
    box-shadow: 0 2px 8px rgba(220, 20, 60, 0.3);
}

.stage-card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stage-card-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-900);
    line-height: 1.4;
}

.stage-card-badge {
    font-size: 10px;
    font-weight: 600;
    color: var(--crimson);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* ============================================================================
   Prospect Form v5 (Odoo-style)
   ============================================================================ */

.prospect-form-v5 { padding: 0; }

.prospect-form-v5-title {
    padding: 8px 16px 6px;
    border-bottom: 1px solid var(--gray-100);
}

.prospect-field-row--name {
    border-bottom: none;
    padding: 2px 0;
    min-height: 36px;
}

.prospect-field-row--name .prospect-field-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-400);
}

.prospect-field-row--name .form-input {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
    height: 32px;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid var(--gray-300);
    background: var(--white);
    width: 100%;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.prospect-field-row--name .form-input:focus {
    border-color: var(--crimson);
    box-shadow: 0 0 0 2px rgba(220, 20, 60, 0.08);
}

.prospect-field-row--name .form-input:hover:not(:focus) {
    border-color: var(--gray-400);
}

.prospect-form-v5-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.prospect-form-v5-col { padding: 6px 16px 10px; }
.prospect-form-v5-col:first-child { border-right: 1px solid var(--gray-300); }

/* Field row */
.prospect-field-row {
    display: flex;
    align-items: center;
    min-height: 32px;
    padding: 2px 0;
    border-bottom: 1px solid var(--gray-50);
    gap: 8px;
}

.prospect-field-row:last-child { border-bottom: none; }

.prospect-field-label {
    width: 138px;
    min-width: 138px;
    font-size: 15px;
    color: var(--gray-500);
    flex-shrink: 0;
    line-height: 1.3;
    padding-top: 2px;
}

.prospect-field-control { flex: 1; min-width: 0; }

.prospect-field-control .form-input,
.prospect-field-control .form-select {
    height: 30px;
    font-size: 15px;
    font-family: inherit;
    padding: 3px 6px;
    border-radius: 4px;
    border: 1px solid transparent;
    background: transparent;
    width: 100%;
    transition: border-color 0.15s, background 0.15s;
    color: var(--gray-800);
}

.prospect-field-control .form-input:focus,
.prospect-field-control .form-select:focus {
    border-color: var(--crimson);
    background: var(--white);
    outline: none;
    box-shadow: 0 0 0 2px rgba(220, 20, 60, 0.08);
}

.prospect-field-control .form-input:hover:not(:focus),
.prospect-field-control .form-select:hover:not(:focus) {
    border-color: var(--gray-300);
    background: var(--gray-50);
}

.prospect-field-section {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--gray-700);
    padding: 10px 0 4px;
    margin-top: 20px;
    border-top: 1px solid var(--gray-200);
    border-bottom: 1px solid var(--gray-300);
    margin-bottom: 2px;
}

.prospect-form-v5-col > .prospect-field-section:first-child {
    margin-top: 0;
    border-top: none;
}

.prospect-field-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 2px 0;
}

.prospect-form-v5-fullrow {
    padding: 8px 16px 10px;
    border-top: 1px solid var(--gray-300);
}

.prospect-form-v5-fullrow-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--gray-700);
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--gray-300);
}

.prospect-form-v5-fullrow-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 32px;
}

.prospect-field-row .toggle-pill {
    font-size: 12px;
    padding: 3px 10px;
    height: auto;
}

.prospect-form-v5 .form-textarea {
    font-size: 15px;
    font-family: inherit;
    padding: 6px 8px;
    min-height: 64px;
    resize: vertical;
}

/* Tab panels */
.modal-tab-panel--datos { padding-bottom: 8px; }

.modal-tab-panel--presupuestos,
.modal-tab-panel--historial { padding: 12px 16px; }

.modal-tab-panel--presupuestos .sale-orders-wrap {
    border: none;
    box-shadow: none;
    padding: 0;
}

.modal-tab-panel--presupuestos .sale-orders-wrap-header { padding: 10px 14px; }

/* ── Sale-order list (desktop: tabla; mobile: cards) ─────────────────────── */
.so-card-list {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-top: 4px;
}

.so-card {
    display: grid;
    grid-template-columns: repeat(6, 1fr) minmax(100px, auto) minmax(130px, 1fr);
    align-items: center;
    border-bottom: 1px solid var(--gray-100);
}
.so-card:last-child { border-bottom: none; }

/* Header row */
.so-card--header {
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200) !important;
}
.so-card--header .so-card__num,
.so-card--header .so-card__date,
.so-card--header .so-card__contract,
.so-card--header .so-card__amount,
.so-card--header .so-card__total,
.so-card--header .so-card__currency,
.so-card--header .so-card__state {
    font-size: 11px;
    font-weight: 700;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.so-card__num {
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.so-attachment-badge {
    font-size: 14px;
    font-weight: 700;
    color: var(--crimson);
    white-space: nowrap;
}
.so-card__date {
    padding: 9px 8px;
    font-size: 12px;
    color: var(--gray-500);
    white-space: nowrap;
}
.so-card__contract {
    padding: 9px 8px;
    font-size: 12px;
    color: var(--gray-600);
    white-space: nowrap;
}
.so-card__amount {
    padding: 9px 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-900);
    min-width: 0;
}
.so-card__total {
    padding: 9px 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-900);
    min-width: 0;
}
.so-card__currency {
    padding: 9px 8px;
    font-size: 12px;
    color: var(--gray-600);
    white-space: nowrap;
}
.so-card__state {
    padding: 9px 8px;
    white-space: nowrap;
}
.so-card__actions {
    display: flex;
    gap: 6px;
    padding: 7px 10px;
    white-space: nowrap;
    justify-content: flex-end;
}
.so-card__actions .btn {
    padding: 4px 10px;
    font-size: 11px;
}
.modal-tab-panel--historial { padding: 12px 16px 8px; }
.modal-tab-panel--historial .timeline-list { max-height: 520px; overflow-y: auto; padding-right: 2px; }

/* ============================================================================
   Prospects Masthead (fila 1: título + tabs + CTA)
   ============================================================================ */

.prospects-masthead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 10px;
    position: relative;
    z-index: 501;
}

/* Loading overlay */
#prospects-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(255, 255, 255, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(1px);
    transition: opacity 0.2s ease;
}

#prospects-loading-overlay.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.prospects-loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--crimson);
    border-radius: 50%;
    animation: prospects-spin 0.7s linear infinite;
}

@keyframes prospects-spin {
    to { transform: rotate(360deg); }
}

.prospects-masthead-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
    flex: 1;
}

.prospects-masthead-left h1 {
    white-space: nowrap;
}

/* ============================================================================
   Prospects Controls Bar (fila 2: organización de vista)
   ============================================================================ */

.prospects-controls-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    margin-bottom: 10px;
    background: var(--gray-50, #f9fafb);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    flex-wrap: wrap;
}

.prospects-ctrl-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.prospects-ctrl-label {
    font-size: 11px;
    color: var(--gray-500);
    white-space: nowrap;
    font-weight: 500;
}

.prospects-ctrl-select {
    font-size: 12px;
    min-width: 116px;
}

.prospects-ctrl-select--narrow {
    min-width: auto;
    width: 64px;
}

.prospects-ctrl-sep {
    width: 1px;
    height: 16px;
    background: var(--gray-200);
    flex-shrink: 0;
    align-self: center;
}

/* ============================================================================
   Filter search row — Solo activos toggle & Limpiar state
   ============================================================================ */

/* Compact quick-toggle chip for "Solo activos" in the search row */
.filter-active-toggle {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 12px;
    padding: 5px 10px;
}

/* "Limpiar" fades when there's nothing to clear */
.btn-clear-filters {
    opacity: 0.45;
    transition: opacity 0.15s, color 0.15s, border-color 0.15s;
}
.btn-clear-filters:hover { opacity: 0.8; }
.btn-clear-filters.btn-clear-active {
    opacity: 1;
    color: var(--crimson);
    border-color: var(--crimson-light, #ffe4e6);
    background: var(--crimson-light, #fff0f1);
}
.btn-clear-filters.btn-clear-active:hover {
    background: var(--crimson-very-light, #ffe4e6);
    border-color: var(--crimson);
}

/* ============================================================================
   Responsive — Prospects header
   ============================================================================ */

@media (max-width: 860px) {
    .prospects-masthead-left h1 { font-size: 17px; }
    .prospects-controls-bar { gap: 6px; padding: 5px 10px; }
}

@media (max-width: 640px) {
    .prospects-masthead {
        flex-wrap: wrap;
        gap: 10px;
    }
    .prospects-masthead-left {
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
    }
    .prospects-masthead > .btn {
        width: 100%;
        justify-content: center;
    }
    .prospects-controls-bar {
        gap: 6px;
    }
    .prospects-ctrl-sep { display: none; }
}

@media (max-width: 480px) {
    .prospects-masthead-left h1 { display: none; }
    .filter-active-toggle { font-size: 11px; padding: 4px 8px; }
}

/* ============================================================================
   Unified Search Bar (Prospects)
   ============================================================================ */

.filters-card--prospects {
    padding: 12px 16px 0;
    display: block;
    position: relative;
    z-index: 200;
    overflow: visible;
}

.filters-collapse-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px 0 4px;
    margin-top: 8px;
    border-top: 1px solid var(--gray-200);
    cursor: pointer;
    color: var(--gray-300);
    transition: color 0.15s, border-color 0.15s;
    user-select: none;
}

.filters-collapse-bar:hover {
    color: var(--gray-500);
    border-top-color: var(--gray-400);
}

#filters-collapse-arrow {
    transition: transform 0.2s ease;
}

#filters-collapse-arrow.arrow-up {
    transform: rotate(180deg);
}

.unified-search-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.unified-search-main {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.unified-search-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.unified-search-wrap {
    position: relative;
    flex: 1;
    min-width: 160px;
}

.unified-search-input {
    width: 100%;
    height: 36px;
    padding: 0 34px 0 12px;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    color: var(--gray-800);
    background: var(--white);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.unified-search-input:focus {
    border-color: var(--crimson);
    box-shadow: 0 0 0 3px rgba(220, 20, 60, 0.08);
}

.unified-search-input::placeholder {
    color: var(--gray-400);
    font-size: 12px;
}

.unified-search-clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    font-size: 18px;
    line-height: 1;
    padding: 0 3px;
    border-radius: 3px;
    transition: color 0.15s;
}

.unified-search-clear-btn:hover { color: var(--gray-700); }

.unified-search-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    z-index: 2000;
    max-height: 280px;
    overflow-y: auto;
}

.unified-search-suggestion {
    padding: 9px 14px;
    font-size: 13px;
    color: var(--gray-700);
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid var(--gray-100);
    user-select: none;
}

.unified-search-suggestion:last-child { border-bottom: none; }

.unified-search-suggestion:hover,
.unified-search-suggestion.active {
    background: var(--crimson-light);
    color: var(--crimson);
}

.unified-search-suggestion strong { font-weight: 700; color: inherit; }

.unified-search-suggestion em {
    font-style: normal;
    font-weight: 600;
    color: var(--gray-900);
}

.unified-search-suggestion:hover em,
.unified-search-suggestion.active em { color: var(--crimson-dark); }

.unified-search-no-results {
    padding: 10px 14px;
    font-size: 12px;
    color: var(--gray-400);
    font-style: italic;
}

/* Active filter chips */
.active-search-chips {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.search-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--crimson-light);
    border: 1px solid rgba(220, 20, 60, 0.25);
    border-radius: var(--radius-full);
    font-size: 12px;
    color: var(--crimson);
    font-weight: 500;
    white-space: nowrap;
}

.search-chip-label { font-weight: 700; }

.search-chip-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--crimson);
    font-size: 15px;
    line-height: 1;
    padding: 0 2px;
    margin-left: 1px;
    opacity: 0.65;
    transition: opacity 0.15s;
}

.search-chip-remove:hover { opacity: 1; }

#btn-toggle-filters.active {
    background: var(--crimson-light);
    border-color: rgba(220, 20, 60, 0.3);
    color: var(--crimson);
}

/* Secondary filters */
.secondary-filters {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--gray-100);
}

.secondary-filters-grid {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.secondary-filters-grid .filter-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 120px;
}

.secondary-filters-grid .filter-item .filter-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.secondary-filters-grid .filter-item.filter-item--active .filter-label {
    color: var(--crimson);
}
.secondary-filters-grid .filter-item.filter-item--active .form-select--sm,
.secondary-filters-grid .filter-item.filter-item--active .form-input--sm,
.secondary-filters-grid .filter-item.filter-item--active .product-picker-search {
    border-color: var(--crimson);
    box-shadow: 0 0 0 2px rgba(220,20,60,0.12);
}
.date-filter-row.filter-item--active .date-filter-row-label {
    color: var(--crimson);
    font-weight: 700;
}
.date-filter-row.filter-item--active .form-input--sm {
    border-color: var(--crimson);
    box-shadow: 0 0 0 2px rgba(220,20,60,0.12);
}

.secondary-filter-active-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: var(--crimson);
    color: var(--white);
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    margin-left: 4px;
}

/* ── Modal overlay fixed (para modales fuera del page-container) ─────────── */
.modal-overlay--fixed {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9900 !important;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-overlay--fixed .modal-content {
    z-index: 9901;
}

/* ── Secondary filters 2-column layout ──────────────────────────────────── */
.sf-layout {
    display: flex;
    gap: 0;
    align-items: flex-start;
}
.sf-col-main {
    flex: 1 1 0;
    min-width: 0;
}
.sf-col-shortcuts {
    flex: 0 0 auto;
    border-left: 1px solid var(--gray-100);
    padding-left: 18px;
    margin-left: 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-self: stretch;
}

/* ── Filter sections ─────────────────────────────────────────────────────── */
.filter-section {
    padding: 10px 0 6px;
}
.sf-col-main .filter-section + .filter-section {
    border-top: 1px solid var(--gray-100);
    margin-top: 4px;
}
.filter-section-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.filter-section--advanced {
    padding-top: 8px;
    padding-bottom: 2px;
    margin-top: auto;
}

/* ── Shortcuts column (probabilidad arriba, fechas abajo) ────────────────── */
.shortcuts-col {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
}

/* ── Shortcuts quadrants grid ────────────────────────────────────────────── */
.shortcuts-quadrants {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-start;
}
.shortcuts-quadrants--date {
    margin-top: 6px;
}

/* ── Date shortcut target selector ──────────────────────────────────────── */
.date-shortcut-block {
    padding-top: 30px;
    display: flex;
    flex-direction: column;
    gap: 0;
}
.date-shortcut-target-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}
.date-shortcut-target-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--gray-400);
    white-space: nowrap;
    flex-shrink: 0;
}
.date-shortcut-target-btns {
    display: flex;
    gap: 3px;
}
.date-target-btn {
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 500;
    color: var(--gray-500);
    background: transparent;
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    line-height: 1.5;
}
.date-target-btn:hover {
    background: var(--gray-100);
    border-color: var(--gray-300);
    color: var(--gray-700);
}
.date-target-btn.active {
    background: var(--gray-700, #374151);
    color: var(--white);
    border-color: var(--gray-700, #374151);
}

/* ── Date filter rows ────────────────────────────────────────────────────── */
.date-filter-rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.date-filter-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}
.date-filter-row-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-600, #4b5563);
    min-width: 130px;
    padding-top: 6px;
    flex-shrink: 0;
}
.date-range-hint {
    font-size: 10px;
    color: var(--gray-400);
    padding-top: 6px;
    flex-shrink: 0;
}
.date-deadline-combined {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
}

/* ── Quick filter chips ──────────────────────────────────────────────────── */
.quick-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 8px 0 2px;
    border-top: 1px solid var(--gray-100);
    margin-top: 8px;
}

.quick-filter-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-600, #4b5563);
    background: var(--gray-50, #f9fafb);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    line-height: 1.4;
}
.quick-filter-chip:hover {
    background: var(--gray-100);
    border-color: var(--gray-300);
}
.quick-filter-chip.active {
    background: var(--crimson, #b91c1c);
    color: var(--white);
    border-color: var(--crimson, #b91c1c);
}
.quick-filter-sep {
    width: 1px;
    height: 18px;
    background: var(--gray-200);
    margin: 0 2px;
}
/* ── Botón Exportar Excel ─────────────────────────────────────────────────── */
.btn-export-excel {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 13px;
    font-size: 12px;
    font-weight: 500;
    background: #e8f5e9;
    border: 1px solid #a5d6a7;
    color: #1b5e20;
    border-radius: 5px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s, border-color 0.12s;
    line-height: 1.5;
}
.btn-export-excel:hover {
    background: #c8e6c9;
    border-color: #66bb6a;
}
.btn-export-excel:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.btn-export-excel--proc {
    opacity: 0.75;
    cursor: not-allowed;
}
.btn-export-excel--ready {
    background: #15803d;
    border-color: #166534;
    color: #fff;
}
.btn-export-excel--ready:hover {
    background: #166534;
    border-color: #14532d;
}
.btn-export-excel--error {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #991b1b;
}
.btn-export-excel--error:hover {
    background: #fee2e2;
    border-color: #f87171;
}
@keyframes btn-exp-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
/* Icon-only export buttons */
.dash-widget-title-group {
    display: flex;
    align-items: center;
    gap: 6px;
}
.btn-icon-excel {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border-radius: 5px;
    border: none;
    background: #1D6F42;
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s, opacity .15s;
    line-height: 1;
}
.btn-icon-excel:hover:not(:disabled) { background: #155c36; }
.btn-icon-excel:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-icon-jpg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border-radius: 5px;
    border: 1px solid #d1d5db;
    background: #f9fafb;
    color: #6b7280;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s, border-color .15s, color .15s;
    line-height: 1;
}
.btn-icon-jpg:hover:not(:disabled) { background: #e5e7eb; border-color: #9ca3af; color: #374151; }
.btn-icon-jpg:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-icon-pdf {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border-radius: 5px;
    border: none;
    background: #DC143C;
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s, opacity .15s;
    line-height: 1;
}
.btn-icon-pdf:hover:not(:disabled) { background: #b01030; }
.btn-icon-pdf:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-pdf-header {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    background: #DC143C;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, opacity .15s;
    white-space: nowrap;
    line-height: 1;
}
.btn-pdf-header:hover:not(:disabled) { background: #b01030; }
.btn-pdf-header:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-exp-spin {
    display: inline-block;
    animation: btn-exp-spin 1s linear infinite;
}

.quick-filter-chip--top5:hover {
    background: #fde68a;
    border-color: #f59e0b;
    color: #78350f;
}
.quick-filter-chip--top5.active {
    background: #d97706;
    color: #fff;
    border-color: #b45309;
}

/* ── Probability chips ───────────────────────────────────────────────────── */
.prob-chip-group {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
}
.prob-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-600, #4b5563);
    background: var(--gray-50, #f9fafb);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.prob-chip:hover {
    background: var(--gray-100);
    border-color: var(--gray-300);
}
.prob-chip.active {
    background: var(--crimson, #b91c1c);
    color: var(--white);
    border-color: var(--crimson, #b91c1c);
}

/* ── Deadline shortcut chips ─────────────────────────────────────────────── */
.deadline-shortcuts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: stretch;
}
.deadline-shortcut-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 7px 10px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm, 6px);
    background: var(--gray-50, #f9fafb);
    min-width: 80px;
}
.deadline-shortcut-label {
    font-size: 9px;
    font-weight: 700;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
}
.deadline-chips {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
}
.deadline-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-600, #4b5563);
    background: var(--gray-50, #f9fafb);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.deadline-chip:hover {
    background: var(--gray-100);
    border-color: var(--gray-300);
}
.deadline-chip.active {
    background: var(--blue-600, #2563eb);
    color: var(--white);
    border-color: var(--blue-600, #2563eb);
}

/* ── Date range inputs ───────────────────────────────────────────────────── */
.date-range-inputs {
    display: flex;
    align-items: center;
    gap: 4px;
}
.date-range-sep {
    color: var(--gray-400);
    font-size: 12px;
    flex-shrink: 0;
}
.filter-item--wide {
    min-width: 260px !important;
}

/* ── Custom filter modal ─────────────────────────────────────────────────── */
.cf-condition-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: var(--gray-50, #f9fafb);
    border: 1px solid var(--gray-100);
    border-radius: 6px;
    margin-bottom: 4px;
    font-size: 12px;
}
.cf-condition-label {
    flex: 1;
    color: var(--gray-700);
}
.cf-condition-remove {
    border: none;
    background: none;
    cursor: pointer;
    color: var(--gray-400);
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
}
.cf-condition-remove:hover { color: var(--crimson); }

/* Filters band (prospect horizontal filters) */
.filters-band {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 10px 12px;
    width: 100%;
    min-width: min-content;
}

.filters-band .filter-item .form-select--sm {
    width: 100%;
    max-width: 92px;
    min-width: 0;
}

/* ── Searchable single-select (filter bar) ─────────────────────────────── */
.ss-wrap {
    position: relative;
    width: 100%;
    max-width: 160px;
}
.ss-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 3px;
    width: 100%;
    padding: 6px 8px;
    font-size: 11px;
    color: var(--gray-900);
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    min-height: 30px;
    text-align: left;
    overflow: hidden;
}
.ss-trigger:hover { border-color: var(--gray-400); }
.ss-wrap.open .ss-trigger {
    border-color: var(--crimson);
    box-shadow: 0 0 0 3px rgba(220,20,60,0.08);
}
.ss-trigger-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--gray-500);
    font-size: 11px;
}
.ss-trigger-text.has-value { color: var(--gray-900); }
.ss-trigger-caret { font-size: 8px; color: var(--gray-400); flex-shrink: 0; }
.ss-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 3px);
    left: 0;
    min-width: 180px;
    max-width: 280px;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0,0,0,0.14);
    z-index: 300;
    overflow: hidden;
}
.ss-wrap.open .ss-dropdown { display: block; }
.ss-search-box {
    padding: 6px 8px;
    border-bottom: 1px solid var(--gray-200);
}
.ss-search-input {
    width: 100%;
    padding: 4px 8px;
    font-size: 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-family: inherit;
    outline: none;
    color: var(--gray-900);
    background: var(--white);
    box-sizing: border-box;
}
.ss-search-input:focus { border-color: var(--crimson); }
.ss-list { max-height: 240px; overflow-y: auto; }
.ss-option {
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    color: var(--gray-700);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ss-option:hover { background: var(--gray-100); }
.ss-option.ss-active {
    background: rgba(220,20,60,0.06);
    color: var(--crimson);
    font-weight: 600;
}
.ss-empty { padding: 8px 10px; font-size: 12px; color: var(--gray-500); }

.ss-option--group {
    font-weight: 700;
    color: var(--crimson);
    letter-spacing: 0.03em;
}

.ss-wrap.ss-disabled .ss-trigger {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
    background: var(--gray-100);
}

/* Form-group context — match .form-select sizing, full width */
.form-group .ss-wrap {
    max-width: none;
}
.form-group .ss-trigger {
    min-height: 38px;
    font-size: 13px;
    padding: 8px 10px;
}
.form-group .ss-trigger-text {
    font-size: 13px;
}
.form-group .ss-dropdown {
    min-width: 100%;
    max-width: none;
}

/* Prospect form modal context — match 15px sizing of other form controls */
.prospect-field-control .ss-wrap { max-width: none; }
.prospect-field-control .ss-trigger {
    height: 30px;
    font-size: 15px;
    padding: 3px 6px;
}
.prospect-field-control .ss-trigger-text { font-size: 15px; }
.prospect-field-control .ss-search-input { font-size: 14px; }
.prospect-field-control .ss-option { font-size: 14px; }

/* Portal mode: dropdown moved to <body> on mobile to escape stacking contexts */
.ss-dropdown--portal {
    display: flex !important;
    flex-direction: column;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    border-radius: 14px 14px 0 0;
    z-index: 3000;
    max-height: 60dvh;
    max-height: 60vh;
    padding-bottom: env(safe-area-inset-bottom, 0);
    overflow: hidden;
    background: var(--white);
    box-shadow: 0 -4px 24px rgba(0,0,0,0.18);
}
/* Portal mode desktop: dropdown moved to <body> to escape modal overflow/stacking */
.ss-dropdown--portal-desktop {
    position: fixed !important;
    min-width: 180px;
    max-width: 320px;
    z-index: 9999;
    display: block !important;
    top: auto;
    left: auto;
}

.ss-dropdown--portal::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--gray-300);
    border-radius: 2px;
    margin: 8px auto 4px;
    flex-shrink: 0;
}
.ss-dropdown--portal .ss-search-box {
    flex-shrink: 0;
    padding: 8px 12px 10px;
    border-bottom: 1px solid var(--gray-200);
}
.ss-dropdown--portal .ss-search-input {
    min-height: 44px;
    font-size: 16px;
    padding: 8px 12px;
    width: 100%;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: var(--white);
    box-sizing: border-box;
    outline: none;
}
.ss-dropdown--portal .ss-search-input:focus { border-color: var(--crimson); }
.ss-dropdown--portal .ss-list {
    flex: 1;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.ss-dropdown--portal .ss-option {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    font-size: 15px;
    white-space: normal;
    cursor: pointer;
}
.ss-dropdown--portal .ss-option:hover,
.ss-dropdown--portal .ss-option:active { background: var(--gray-50); }
.ss-dropdown--portal .ss-option.ss-active { color: var(--crimson); font-weight: 600; }
.ss-dropdown--portal .ss-empty {
    padding: 16px;
    text-align: center;
    color: var(--gray-400);
    font-size: 13px;
}

.filters-band__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    flex-shrink: 0;
}

/* ============================================================================
   Product Picker
   ============================================================================ */

.product-picker {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.product-picker-selected {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-height: 0;
}

.product-picker-selected:empty { display: none; }

.product-picker-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: var(--crimson-light);
    border: 1px solid rgba(220, 20, 60, 0.2);
    color: var(--crimson);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    user-select: none;
}

.product-picker-chip-remove {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-size: 15px;
    line-height: 1;
    color: var(--crimson);
    opacity: 0.65;
    transition: opacity 0.15s;
}

.product-picker-chip-remove:hover { opacity: 1; }

.product-picker-input-wrap { position: relative; }

@keyframes pp-spin { to { transform: translateY(-50%) rotate(360deg); } }
.product-picker-spinner {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--crimson, #c0392b);
    border-radius: 50%;
    animation: pp-spin 0.6s linear infinite;
    pointer-events: none;
}

.product-picker-search {
    width: 100%;
    max-width: none;
}

.product-picker-list {
    position: fixed;
    z-index: 9999;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-modal);
    max-height: 220px;
    overflow-y: auto;
    display: none;
}

.product-picker-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--gray-700);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--gray-100);
    transition: background 0.1s;
}

.product-picker-item:last-child { border-bottom: none; }
.product-picker-item:hover { background: var(--gray-50); }

.product-picker-item.selected {
    background: var(--crimson-light);
    color: var(--crimson);
    font-weight: 500;
}

.product-picker-item.selected::after {
    content: '\2713';
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    margin-left: 6px;
}

.product-picker-empty {
    padding: 10px 12px;
    font-size: 13px;
    color: var(--gray-400);
    text-align: center;
}

/* ============================================================================
   Company Picker
   ============================================================================ */

.company-picker-wrap { position: relative; }

.company-picker-dropdown {
    display: none;
    position: fixed;
    z-index: 9999;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-modal);
    max-height: 220px;
    overflow-y: auto;
}

.company-picker-item {
    padding: 7px 12px;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--gray-800);
    border-bottom: 1px solid var(--gray-100);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.company-picker-item:last-child { border-bottom: none; }

.company-picker-item:hover {
    background: var(--crimson-light);
    color: var(--crimson-dark);
}

.company-picker-empty {
    padding: 10px 12px;
    font-size: 0.85rem;
    color: var(--gray-400);
}

/* ============================================================================
   Sale Orders
   ============================================================================ */

.sale-orders-wrap {
    margin: 10px 12px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.sale-orders-wrap-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.sale-orders-wrap-header h4 {
    font-size: 11px;
    font-weight: 700;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.sale-orders-wrap-body { padding: 4px 0 0; }

.modal-tab-panel--presupuestos .sale-orders-wrap-body { padding: 4px 0 0; }

.sale-orders-wrap .data-table th,
.sale-orders-wrap .data-table td {
    padding: 8px 12px;
    font-size: 12px;
}

.prospect-sale-orders-wrap {
    border-top: 1px solid var(--gray-200);
    padding-top: 16px;
    margin-top: 16px;
}

.sale-orders-list .data-table { font-size: 12px; }

.sale-order-lines-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.sale-order-lines-table-wrap .data-table {
    width: 100%;
    margin-top: 8px;
}

.sale-order-lines-table td,
.sale-order-lines-table th { padding: 6px 8px; }

/* ── Sale-order line cards ─────────────────────────────────────────────────── */
.so-lines-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.so-line-row {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.so-line-product-wrap .ss-wrap,
.so-line-product-wrap .form-select { width: 100%; max-width: none; }

.so-line-extra {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}
.so-line-ctrl--linea  { flex: 0 1 160px; min-width: 100px; }
.so-line-ctrl--sku    { flex: 0 1 90px;  min-width: 70px; }
.so-line-ctrl--detalle { flex: 1 1 120px; min-width: 100px; }
.so-line-extra .so-line-ctrl .form-select,
.so-line-extra .so-line-ctrl .form-input { width: 100%; padding: 5px 8px; font-size: 13px; }

.so-line-controls {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.so-line-ctrl {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 60px;
}

.so-line-ctrl--total { flex: 0 0 auto; min-width: 70px; }

.so-line-ctrl-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.so-line-ctrl .form-input {
    width: 100%;
    padding: 5px 8px;
    font-size: 13px;
}

.so-line-total {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-800);
    padding: 5px 0;
}

.so-line-remove { align-self: flex-end; flex-shrink: 0; }

/* Sale-order modal layout */
.so-fields-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 32px;
    align-items: start;
    margin-bottom: 0;
}

.so-col {
    display: flex;
    flex-direction: column;
}

.so-col .form-group { margin-bottom: 14px; }

.so-label-note {
    font-weight: 400;
    color: var(--gray-400);
    font-size: 11px;
}

.so-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    color: var(--gray-900);
    padding: 10px 0 2px;
    margin: 0;
    user-select: none;
}

.so-checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--crimson);
}

.so-revenue-block {
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 16px 18px 6px;
    background: var(--gray-50);
}

.so-revenue-block__title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--gray-500);
    margin: 0 0 14px 0;
}

.so-revenue-block .form-group { margin-bottom: 14px; }
.so-revenue-block .form-group.so-revenue-block__last { margin-bottom: 4px; }

/* Processing lines */
.processing-lines-wrap {
    margin: 10px 12px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.processing-lines-wrap-header {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.processing-lines-wrap-header h4 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
}

.processing-lines-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 14px;
}

.processing-lines-empty {
    font-size: 13px;
    color: var(--gray-500);
    font-style: italic;
}

.processing-line-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: var(--blue-bg);
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    font-size: 12px;
    color: var(--blue-700);
    font-weight: 500;
}

/* ============================================================================
   Pivot Table
   ============================================================================ */

.pivot-container {
    background: var(--white);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-top: 16px;
}

/* Top bar: Solo activos + chips */
.pivot-top-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px 8px;
    flex-wrap: wrap;
}

.pivot-active-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

/* Accordions */
.pivot-accordion {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    overflow: hidden;
}

.pivot-accordion-hdr {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    background: var(--gray-50);
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    text-align: left;
    transition: background 0.15s;
}
.pivot-accordion-hdr:hover { background: var(--gray-100); }

.pivot-acc-dot {
    font-size: 9px;
    color: var(--crimson, #DC143C);
    line-height: 1;
}

.pivot-acc-caret {
    margin-left: auto;
    font-size: 11px;
    color: var(--gray-400);
}

.pivot-accordion-body {
    padding: 12px 14px;
    background: var(--white);
}

.pivot-presets-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0 10px;
    border-bottom: 1px solid var(--gray-100, #f3f4f6);
    margin-bottom: 10px;
}
.pivot-presets-label {
    font-size: 11px;
    color: var(--gray-400, #9ca3af);
    margin-right: 2px;
    white-space: nowrap;
}
.pivot-preset-chip {
    background: none;
    border: 1px solid var(--gray-300, #d1d5db);
    border-radius: 12px;
    padding: 3px 11px;
    font-size: 12px;
    color: var(--gray-600, #4b5563);
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
    white-space: nowrap;
}
.pivot-preset-chip:hover {
    background: var(--gray-50, #f9fafb);
    border-color: var(--gray-400, #9ca3af);
}
.pivot-preset-chip--active {
    background: rgba(220,20,60,.07);
    border-color: var(--crimson, #DC143C);
    color: var(--crimson, #DC143C);
    font-weight: 500;
}

.pivot-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin: 0;
    padding: 0;
    background: none;
    border: none;
    border-radius: 0;
}

.pivot-fbar-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pivot-fbar-group--check {
    flex-direction: row;
    align-items: center;
    padding-bottom: 2px;
}

/* ── Pivot filter sections (grouping within the accordion) ── */
.pivot-fbar-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}
.pivot-fbar-section + .pivot-fbar-section {
    padding-top: 10px;
    border-top: 1px solid var(--gray-100);
}
.pivot-fbar-section-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.pivot-fbar-section-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}
.pivot-fbar-group--daterange {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.pivot-fbar-group--daterange .pivot-fbar-datepair {
    display: flex;
    gap: 4px;
    align-items: center;
}
.pivot-fbar-group--daterange .pivot-fbar-datepair input[type="date"] {
    font-size: 12px;
    padding: 4px 6px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    background: var(--white);
    color: var(--gray-800);
    width: 128px;
}
.pivot-fbar-group--daterange .pivot-fbar-datepair input[type="date"]:focus {
    outline: none;
    border-color: var(--primary);
}
.pivot-fbar-group--probrange {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.pivot-fbar-group--probrange .pivot-fbar-probpair {
    display: flex;
    gap: 4px;
    align-items: center;
}
.pivot-fbar-group--probrange .pivot-fbar-probpair input[type="number"] {
    font-size: 12px;
    padding: 4px 6px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    background: var(--white);
    color: var(--gray-800);
    width: 60px;
    text-align: center;
}
.pivot-fbar-group--probrange .pivot-fbar-probpair input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
}
.pivot-fbar-datepair-sep,
.pivot-fbar-probpair-sep {
    color: var(--gray-400);
    font-size: 11px;
}

.pivot-view-chip-clear {
    border: none;
    background: none;
    cursor: pointer;
    padding: 0 2px;
    color: var(--gray-400);
    font-size: 14px;
    line-height: 1;
    margin-left: 2px;
}
.pivot-view-chip-clear:hover {
    color: var(--gray-700);
}

.pivot-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin: 0;
    padding: 0;
    background: none;
    border: none;
}

.pivot-ctrl-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pivot-status-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
    white-space: nowrap;
}

.pivot-ctrl-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.pivot-ctrl-group .form-select {
    min-width: 160px;
    font-size: 13px;
}

.pivot-status-text {
    font-size: 12px;
    color: var(--gray-400);
}

.pivot-table-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(96vh - 120px);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
}

.pivot-table-container { min-width: 100%; }

.pivot-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    font-size: 11px;
}

.pivot-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--gray-50);
}

.pivot-table th {
    padding: 4px 8px;
    text-align: left;
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-700);
    border-bottom: 2px solid var(--gray-300);
    border-right: 1px solid var(--gray-200);
    background: var(--gray-50);
    white-space: nowrap;
    line-height: 1.3;
}

.pivot-table th.pivot-row-header,
.pivot-table th.pivot-dimension-header {
    background: var(--crimson-light);
    color: var(--crimson);
    font-weight: 700;
    position: sticky;
    left: 0;
    z-index: 11;
    min-width: 90px;
}

.pivot-table th.pivot-total-col {
    background: var(--gray-100);
    font-weight: 700;
    color: var(--gray-900);
}

.pivot-table td {
    padding: 3px 8px;
    border-bottom: 1px solid var(--gray-200);
    border-right: 1px solid var(--gray-200);
    text-align: right;
    line-height: 1.2;
}

.pivot-table td.pivot-row-header {
    font-weight: 600;
    color: var(--gray-900);
    text-align: left;
    position: sticky;
    left: 0;
    z-index: 5;
    background: var(--white);
    min-width: 100px;
}

.pivot-table td.pivot-year-col,
.pivot-table th.pivot-year-header {
    min-width: 56px;
    width: 56px;
    text-align: center;
    font-weight: 600;
    color: var(--gray-500);
}

.pivot-table tbody tr:hover { background: var(--gray-50); }
.pivot-table tbody tr:hover td.pivot-row-header { background: var(--gray-50); }

.pivot-table tr.pivot-total-row {
    background: var(--gray-100);
    font-weight: 600;
}

.pivot-table tr.pivot-total-row td {
    border-top: 2px solid var(--gray-300);
    border-bottom: 2px solid var(--gray-300);
}

.pivot-table tr.pivot-total-row td.pivot-row-header {
    background: var(--gray-100);
    position: sticky;
    left: 0;
    z-index: 6;
}

.pivot-table td.pivot-total-col {
    background: var(--gray-50);
    font-weight: 600;
}

.pivot-table tr.pivot-total-row td.pivot-total-col {
    background: var(--gray-200);
    font-weight: 700;
}

.pivot-table tr.pivot-metric-row th.pivot-metric-desc {
    background: var(--crimson);
    color: var(--white);
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 4px 12px;
    border: none;
    position: sticky;
    top: 0;
    z-index: 12;
}

.pivot-cell {
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-900);
    white-space: nowrap;
}

.pivot-cell--empty {
    color: var(--gray-300);
    font-weight: 400;
}

.pivot-cell--count {
    text-align: right;
    color: var(--gray-500);
    font-size: 11px;
    font-weight: 400;
    padding: 3px 6px;
    border-left: 1px solid var(--gray-100);
    min-width: 36px;
    width: 36px;
}

.pivot-subheader-row th {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--gray-400);
    padding: 3px 8px;
    background: var(--gray-50);
    white-space: nowrap;
}

.pivot-col-subheader--count {
    border-left: 1px solid var(--gray-100);
    color: var(--gray-400);
}

.pivot-col-subheader--nth {
    border-left: 1px solid var(--gray-200);
}

.pivot-cell--nth {
    border-left: 1px solid var(--gray-100);
}

/* Metrics dropdown widget */
.pivot-metrics-widget {
    position: relative;
}

.pivot-metrics-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    min-width: 160px;
    color: var(--gray-900);
    text-align: left;
}

.pivot-metrics-caret {
    flex-shrink: 0;
    color: var(--gray-400);
    transition: transform 0.15s;
}

.pivot-metrics-dropdown.is-open ~ * .pivot-metrics-caret,
.pivot-metrics-widget:has(.pivot-metrics-dropdown.is-open) .pivot-metrics-caret {
    transform: rotate(180deg);
}

.pivot-metrics-dropdown {
    display: none;
    position: fixed;
    min-width: 210px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    z-index: 9999;
    padding: 6px 0;
}

.pivot-metrics-dropdown.is-open {
    display: block;
}

.pivot-metric-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--gray-700);
    cursor: pointer;
    white-space: nowrap;
    padding: 5px 14px;
    transition: background 0.1s;
}

.pivot-metric-check:hover {
    background: var(--gray-50);
}

.pivot-metric-check input[type="checkbox"] {
    cursor: pointer;
    accent-color: var(--crimson);
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* Metric chips (rendered inside pivot-active-filter-bar) */

.pivot-metric-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    background: var(--crimson-light, #fdecea);
    color: var(--crimson);
    border: 1px solid color-mix(in srgb, var(--crimson) 25%, transparent);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    line-height: 1.6;
    margin: 1px 0;
}

.pivot-metric-chip-label {
    color: var(--crimson);
    opacity: 0.65;
    font-weight: 400;
}

.pivot-metric-chip-value {
    color: var(--crimson);
    font-weight: 600;
}

.pivot-metric-chip-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--crimson);
    font-size: 15px;
    line-height: 1;
    padding: 0 0 1px 0;
    display: flex;
    align-items: center;
    opacity: 0.7;
    transition: opacity 0.1s;
}

.pivot-metric-chip-remove:hover {
    opacity: 1;
}

.pivot-grand-total {
    background: var(--crimson-light);
    color: var(--crimson);
    font-weight: 700;
}

.pivot-row-header--group {
    background: var(--gray-50);
    border-right: 2px solid var(--gray-300);
    vertical-align: top;
    padding-top: 8px;
}

.pivot-row-header--sub {
    font-weight: 400;
    color: var(--gray-600);
    padding-left: 20px;
    font-size: 12px;
}

.pivot-subtotal-row td {
    background: var(--gray-100);
    border-top: 1px solid var(--gray-300);
    font-weight: 600;
}

.pivot-subtotal-grand {
    background: var(--gray-200);
    font-weight: 700;
}

.pivot-table strong { color: var(--gray-900); }

.pivot-value {
    font-size: 12px;
    color: var(--gray-900);
    font-weight: 500;
    line-height: 1.2;
}

.pivot-count {
    font-size: 10px;
    color: var(--gray-500);
    line-height: 1.1;
}

/* ============================================================================
   Timeline
   ============================================================================ */

.timeline-wrap {
    margin-top: 24px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    overflow: hidden;
}

.timeline-wrap-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.timeline-wrap-header h4 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.timeline-wrap-body {
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
}

.timeline-loading-text {
    font-size: 13px;
    color: var(--gray-400);
    margin: 0;
    padding: 4px 0;
}

.timeline-empty {
    font-size: 13px;
    color: var(--gray-400);
    text-align: center;
    padding: 24px 0;
    margin: 0;
}

.timeline-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    position: relative;
}

.timeline-entry {
    display: flex;
    gap: 10px;
    position: relative;
    padding-bottom: 18px;
}

.timeline-entry:last-child { padding-bottom: 0; }

.timeline-entry::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 18px;
    bottom: 0;
    width: 1px;
    background: var(--gray-200);
}

.timeline-entry:last-child::before { display: none; }

/* Dots */
.timeline-entry-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 2px;
    z-index: 1;
    background: var(--gray-300);
    box-shadow: 0 0 0 2px var(--white), 0 0 0 3px var(--gray-300);
}

.timeline-entry--stage .timeline-entry-dot    { background: var(--crimson);       box-shadow: 0 0 0 2px var(--white), 0 0 0 3px var(--crimson); }
.timeline-entry--message .timeline-entry-dot  { background: var(--gray-500);      box-shadow: 0 0 0 2px var(--white), 0 0 0 3px var(--gray-500); }
.timeline-entry--creation .timeline-entry-dot { background: var(--tl-creation);   box-shadow: 0 0 0 2px var(--white), 0 0 0 3px var(--tl-creation); }
.timeline-entry--sale .timeline-entry-dot     { background: var(--tl-sale);       box-shadow: 0 0 0 2px var(--white), 0 0 0 3px var(--tl-sale); }

/* Type badges */
.timeline-type-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 1px 6px;
    border-radius: 3px;
    line-height: 1.6;
    vertical-align: middle;
}

.timeline-type-badge--stage    { background: var(--tl-stage-bg);    color: var(--crimson); }
.timeline-type-badge--message  { background: var(--gray-100);       color: var(--gray-500); }
.timeline-type-badge--email    { background: var(--blue-bg);        color: var(--tl-sale); }
.timeline-type-badge--creation { background: var(--tl-creation-bg); color: var(--tl-creation); }
.timeline-type-badge--sale     { background: var(--tl-sale-bg);     color: var(--tl-sale); }

/* Content */
.timeline-entry-content { flex: 1; min-width: 0; }

.timeline-entry-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 3px;
}

.timeline-author {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-800);
}

.timeline-date {
    font-size: 12px;
    color: var(--gray-400);
}

.timeline-body {
    font-size: 13px;
    color: var(--gray-600);
    line-height: 1.5;
    margin-top: 3px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Field changes */
.timeline-changes {
    list-style: none;
    margin: 6px 0 0 0;
    padding: 7px 10px;
    background: var(--gray-50);
    border-radius: 4px;
    border-left: 2px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.timeline-entry--stage .timeline-changes { border-left-color: var(--crimson-light); }

.timeline-change-item {
    font-size: 12px;
    color: var(--gray-600);
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.timeline-change-field { font-weight: 600; color: var(--gray-700); }
.timeline-change-old   { color: var(--gray-400); text-decoration: line-through; }
.timeline-change-arrow { color: var(--gray-400); font-size: 11px; }
.timeline-change-new   { font-weight: 500; color: var(--gray-800); }

/* Minimal timeline (Historial tab) */
.tl-item {
    padding: 7px 0 7px 10px;
    border-left: 2px solid var(--gray-200);
    margin-bottom: 8px;
}

.tl-item:last-child { margin-bottom: 0; }
.tl-item--stage     { border-left-color: var(--crimson); }
.tl-item--creation  { border-left-color: var(--tl-creation); }
.tl-item--sale,
.tl-item--email     { border-left-color: var(--tl-sale); }
.tl-item--message   { border-left-color: var(--gray-300); }

.tl-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tl-badge {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 1px 5px;
    border-radius: 3px;
    flex-shrink: 0;
    background: var(--gray-100);
    color: var(--gray-500);
}

.tl-badge--stage    { background: var(--tl-stage-bg); color: var(--crimson); }
.tl-badge--creation { background: var(--tl-creation-bg); color: var(--tl-creation); }
.tl-badge--sale,
.tl-badge--email    { background: var(--tl-sale-bg); color: var(--tl-sale); }

.tl-actor {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.tl-date {
    font-size: 11px;
    color: var(--gray-400);
    margin-left: auto;
    white-space: nowrap;
    flex-shrink: 0;
}

.tl-body {
    font-size: 12px;
    color: var(--gray-600);
    margin-top: 4px;
    line-height: 1.4;
    word-break: break-word;
}

.tl-changes {
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tl-change {
    font-size: 11px;
    color: var(--gray-600);
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.tl-change-field { font-weight: 600; color: var(--gray-700); }
.tl-change-old   { color: var(--gray-400); text-decoration: line-through; }
.tl-change-arrow { color: var(--gray-400); }
.tl-change-new   { font-weight: 500; color: var(--gray-800); }

/* ============================================================================
   Contacts — Kanban View & Detail
   ============================================================================ */

.contacts-kanban-container { margin-top: 16px; }

.contacts-kanban-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    padding: 20px 0;
}

.contact-relation-cell {
    max-width: 220px;
    font-size: 13px;
    color: var(--gray-600);
}

.contact-card-relation {
    font-size: 13px;
    color: var(--gray-600);
    margin-bottom: 8px;
}

.contact-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.contact-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--crimson);
}

.contact-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--gray-200);
}

.contact-card-id {
    font-size: 11px;
    color: var(--gray-500);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.contact-card-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.contact-card-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0;
    line-height: 1.4;
}

.contact-card-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--gray-700);
}

.contact-card-info svg {
    flex-shrink: 0;
    stroke: var(--gray-500);
    width: 16px;
    height: 16px;
}

.contact-card-info span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Contact form layouts */
.contact-form-sections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 12px 12px 0;
}

.contact-form-sections-full {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 16px;
}

.contact-form-sections-full > .full-span { grid-column: 1 / -1; }

.contact-relations-wrap {
    padding: 10px 12px 12px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.contact-relations-wrap .modal-relation-add {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 10px;
}

.contact-relations-wrap .modal-relation-add .form-select,
.contact-relations-wrap .modal-relation-add .form-input {
    flex: 1;
    min-width: 100px;
    padding: 8px 10px;
    font-size: 13px;
}

/* Companies list */
.companies-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.company-link-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
}

.company-link-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.company-link-position {
    color: var(--gray-500);
    font-size: 12px;
}

/* ============================================================================
   Geo Detail
   ============================================================================ */

.geo-detail-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 20px;
    align-items: start;
}

.geo-panels-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

.geo-member-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.geo-member-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 14px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 13px;
    color: var(--gray-700);
}

.geo-member-item:last-child { border-bottom: none; }
.geo-member-item:hover { background: var(--gray-50); }
.geo-member-item.is-checked { background: rgba(220,20,60,0.06); border-left: 2px solid rgba(220,20,60,0.4); }
.geo-member-item input[type="checkbox"] { accent-color: var(--crimson); width: 15px; height: 15px; cursor: pointer; }

.geo-chips-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 0 0 10px;
}

.geo-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 6px 3px 9px;
    background: rgba(220,20,60,0.08);
    border: 1px solid rgba(220,20,60,0.22);
    border-radius: 12px;
    font-size: 12px;
    color: var(--gray-700);
    line-height: 1.4;
}

.geo-chip-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--crimson);
    font-size: 13px;
    padding: 0 2px;
    line-height: 1;
    opacity: 0.65;
}
.geo-chip-remove:hover { opacity: 1; }

.geo-member-code {
    font-size: 11px;
    color: var(--gray-500);
    margin-left: 6px;
}

/* ============================================================================
   Responsive — Views
   ============================================================================ */

@media (max-width: 900px) {
    .contact-form-sections,
    .contact-form-sections-full,
    .contact-relations-wrap { grid-template-columns: 1fr; }

    .contact-form-sections-full > .full-span { grid-column: auto; }
    .geo-detail-layout { grid-template-columns: 1fr; }
    .geo-panels-row { grid-template-columns: 1fr; }
    .so-fields-grid { grid-template-columns: 1fr; }
}

@media (max-width: 767px) {
    .contacts-kanban-grid { grid-template-columns: 1fr; }
    .kanban-column { min-width: 300px; max-width: 300px; }
    .modal-content { width: 95%; max-height: 95vh; }
    .modal-detail-row { grid-template-columns: 1fr; }
    .stages-grid { grid-template-columns: 1fr; }

    .modal-content-small {
        width: 95%;
        max-width: 100%;
    }
}

@media (max-width: 680px) {
    .prospect-form-v5-cols { grid-template-columns: 1fr; }
    .prospect-form-v5-col:first-child { border-right: none; border-bottom: 1px solid var(--gray-300); }
    .prospect-form-v5-fullrow-grid { grid-template-columns: 1fr; gap: 0; }
}

@media (max-width: 1200px) {
    #modal-prospect-form { grid-template-columns: 1fr; }
}

/* ============================================================================
   Responsive — Prospects: Mobile (<768px)
   ============================================================================ */

@media (max-width: 767px) {

    /* Vista Pivote: no disponible en mobile */
    #view-pivot { display: none !important; }

    /* Kanban: scroll horizontal con snap por columna */
    .kanban-container {
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        padding: 0 0 20px;
    }
    .kanban-board {
        padding: 8px 16px;
        gap: 12px;
    }
    .kanban-column {
        min-width: 88vw;
        max-width: 88vw;
        scroll-snap-align: start;
        flex-shrink: 0;
        flex: 0 0 auto;
    }

    /* Vista Lista: ocultar columnas Comercial y País */
    #prospects-list-table th:nth-child(4),
    #prospects-list-table td:nth-child(4),
    #prospects-list-table th:nth-child(5),
    #prospects-list-table td:nth-child(5) { display: none; }

    /* Modales grandes: full-screen */
    #prospect-modal,
    #sale-order-modal {
        align-items: stretch;
        justify-content: stretch;
    }
    #prospect-modal .modal-content,
    #sale-order-modal .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 100vh;
        max-height: 100dvh;
        height: 100%;
        border-radius: 0;
        margin: 0;
        animation: none;
        display: flex;
        flex-direction: column;
    }
    /* El body scrollea internamente; sin max-height heredado del base */
    #prospect-modal .modal-body,
    #sale-order-modal .modal-body {
        flex: 1 1 0;
        min-height: 0;
        max-height: none;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        /* Espacio para el footer fijo */
        padding-bottom: 72px;
    }
    /* Footer fijo al viewport: siempre visible sin importar el scroll */
    #prospect-modal .modal-footer,
    #sale-order-modal .modal-footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 2100;
        border-radius: 0;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    /* Modales pequeños: bottom-sheet */
    #change-stage-modal,
    #confirm-stage-modal,
    #confirm-delete-modal,
    #app-confirm-modal,
    #confirm-delete-so-modal,
    #views-modal {
        align-items: flex-end;
        justify-content: flex-end;
    }
    #change-stage-modal .modal-content,
    #confirm-stage-modal .modal-content,
    #confirm-delete-modal .modal-content,
    #app-confirm-modal .modal-content,
    #confirm-delete-so-modal .modal-content,
    #views-modal .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 90vh;
        max-height: 90dvh;
        border-radius: var(--radius-md) var(--radius-md) 0 0;
        margin: 0;
        animation: mobileSheetIn 0.25s ease-out;
    }
    /* Filtro personalizado (usa .modal-overlay--fixed como raíz) */
    #custom-filter-modal.modal-overlay--fixed {
        align-items: flex-end;
        justify-content: flex-end;
    }
    #custom-filter-modal .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 90vh;
        max-height: 90dvh;
        border-radius: var(--radius-md) var(--radius-md) 0 0;
        margin: 0;
        animation: mobileSheetIn 0.25s ease-out;
    }
    @keyframes mobileSheetIn {
        from { transform: translateY(40px); opacity: 0.7; }
        to   { transform: translateY(0);    opacity: 1; }
    }

    /* Quick filter bar: oculto por defecto, se muestra al abrir filtros */
    .quick-filter-bar { display: none; }
    .quick-filter-bar.mobile-visible { display: flex; }

    /* Active filter chips bar: oculta en mobile; visible solo al abrir filtros */
    #active-filter-bar { display: none !important; }
    .filters-card--prospects:has(#btn-toggle-filters.active) #active-filter-bar { display: block !important; }

    /* Kanban card actions: siempre visibles en touch (no dependen de hover) */
    .kanban-card-actions { display: flex; }
    .kanban-card-action-btn { min-width: 44px; min-height: 44px; width: auto; height: auto; }

    /* Touch targets mínimos 44px */
    .view-btn          { min-height: 44px; padding: 0 10px; }
    .btn               { min-height: 44px; }
    .quick-filter-chip { min-height: 44px; }
    .modal-close       { min-width: 44px; min-height: 44px; }

    /* Search row: input en fila propia, acciones debajo a ancho completo */
    .unified-search-row {
        flex-wrap: wrap;
        gap: 6px;
        align-items: stretch;
    }
    .unified-search-main {
        flex: 1 0 100%;
        flex-wrap: wrap;
        align-items: center;
    }
    .unified-search-wrap { flex: 1 0 100%; min-width: 0; }
    .active-search-chips { flex: 0 0 100%; min-width: 0; }
    .unified-search-actions {
        width: 100%;
        flex-shrink: 0;
        justify-content: space-between;
    }

    /* "Solo activos": misma altura que los botones vecinos */
    .filter-active-toggle {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    /* ── Secondary filters: columna única en mobile ─────────────────────── */

    /* Pasar de 2 columnas a layout apilado */
    .sf-layout { flex-direction: column; gap: 0; }
    .sf-col-shortcuts {
        border-left: none;
        padding-left: 0;
        margin-left: 0;
        border-top: 1px solid var(--gray-200);
        padding-top: 10px;
        margin-top: 6px;
    }

    /* Grid de selectores: 2 columnas compactas */
    .secondary-filters-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        align-items: end;
    }
    .secondary-filters-grid .filter-item { min-width: 0; }
    .secondary-filters-grid .filter-item .form-select--sm { max-width: none; width: 100%; }

    /* Filas de fecha: apilar etiqueta encima de los inputs */
    .date-filter-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    .date-filter-row-label { min-width: 0; padding-top: 0; }
    .date-range-inputs { gap: 4px; flex-wrap: wrap; align-items: center; }
    .date-range-inputs .form-input { width: 130px; min-width: 0; }

    /* Accesos rápidos: más compacto */
    .date-shortcut-block { padding-top: 10px; }
    .shortcuts-quadrants { flex-wrap: wrap; gap: 6px; }
    .deadline-shortcut-group { min-width: 0; }
    .shortcuts-col { gap: 10px; }

    /* Probabilidad: chips en fila */
    .prob-chip-group { justify-content: flex-start; flex-wrap: wrap; }

    /* Stage pipeline: pills individuales con scroll horizontal */
    .stage-pipeline-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        padding: 8px 12px;
        white-space: nowrap;
    }
    .stage-pipeline {
        display: inline-flex;
        width: auto;
        gap: 5px;
        align-items: center;
    }
    /* Cada etapa: pill independiente (anula la barra conectada del base) */
    .stage-step {
        flex: 0 0 auto !important;
        border: 1.5px solid var(--gray-300) !important;
        border-radius: var(--radius-full) !important;
        padding: 6px 13px !important;
        font-size: 11px !important;
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .stage-step:last-child {
        border-right: 1.5px solid var(--gray-300) !important;
        border-radius: var(--radius-full) !important;
    }
    .stage-step--active {
        max-width: 160px !important;
        font-size: 12px !important;
        box-shadow: 0 2px 10px rgba(220, 20, 60, 0.3);
    }
    .stage-step--active:last-child {
        border-right-color: var(--crimson) !important;
    }
    .stage-step--done { opacity: 0.65; }

    /* Controls bar: ocultar en mobile; visible solo al abrir filtros */
    .prospects-controls-bar { display: none; flex-wrap: wrap; }
    .page-container:has(#btn-toggle-filters.active) .prospects-controls-bar { display: flex; }
    #group-by-container     { width: 100%; }

    /* ── Contacts ──────────────────────────────────────────────────────────── */

    /* Page header: acciones en fila completa con wrapping */
    .page-header-actions { width: 100%; flex-wrap: wrap; }

    /* Lista: ocultar columnas Teléfono (4ª) y Modificado (5ª) */
    #contacts-table th:nth-child(4),
    #contacts-table td:nth-child(4),
    #contacts-table th:nth-child(5),
    #contacts-table td:nth-child(5) { display: none; }

    /* Modal de edición: full-screen */
    #contact-modal { align-items: stretch; justify-content: stretch; }
    #contact-modal .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 100vh;
        max-height: 100dvh;
        height: 100%;
        border-radius: 0;
        margin: 0;
        animation: none;
    }

    /* Modales de confirmación: bottom-sheet */
    #type-change-confirm-modal,
    #delete-contact-modal { align-items: flex-end; justify-content: flex-end; }
    #type-change-confirm-modal .modal-content,
    #delete-contact-modal .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 90vh;
        max-height: 90dvh;
        border-radius: var(--radius-md) var(--radius-md) 0 0;
        margin: 0;
        animation: mobileSheetIn 0.25s ease-out;
    }

    /* Footer del modal de edición: evitar desbordamiento en pantallas < 380px */
    #contact-modal .modal-footer {
        flex-wrap: wrap;
        gap: 8px;
    }
    #contact-modal .modal-footer a#contact-modal-open-full {
        width: 100%;
        text-align: center;
    }

    /* ── Budgets ─────────────────────────────────────────────────────────────── */

    /* Lista: ocultar columnas Fecha (2ª) y Empresa (4ª) */
    #budgets-table th:nth-child(2),
    #budgets-table td:nth-child(2),
    #budgets-table th:nth-child(4),
    #budgets-table td:nth-child(4) { display: none; }

    /* Modal Nuevo presupuesto: full-screen */
    #new-budget-modal { align-items: stretch; justify-content: stretch; }
    #new-budget-modal .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 100vh;
        max-height: 100dvh;
        height: 100%;
        border-radius: 0;
        margin: 0;
        animation: none;
    }

    /* Modal Eliminar presupuesto: bottom-sheet */
    #delete-modal { align-items: flex-end; justify-content: flex-end; }
    #delete-modal .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 90vh;
        max-height: 90dvh;
        border-radius: var(--radius-md) var(--radius-md) 0 0;
        margin: 0;
        animation: mobileSheetIn 0.25s ease-out;
    }

    /* Modal detalle presupuesto (usa .modal-overlay--fixed como raíz): bottom-sheet */
    #budget-modal.modal-overlay--fixed {
        align-items: flex-end;
        justify-content: flex-end;
    }
    #budget-modal .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 90vh;
        max-height: 90dvh;
        border-radius: var(--radius-md) var(--radius-md) 0 0;
        margin: 0;
        animation: mobileSheetIn 0.25s ease-out;
    }

    /* Budget form: cabecera envuelve en pantallas muy chicas */
    .budget-form-header { flex-wrap: wrap; }

    /* Presupuestos tab: más respiro en los bordes */
    .modal-tab-panel--presupuestos { padding: 16px 16px 20px; }

    /* ---- Tabla de líneas de presupuesto → card por fila ---- */
    .budget-lines-table-wrap { overflow-x: visible; }
    .budget-lines-table,
    .budget-lines-table tbody,
    .budget-lines-table tr { display: block; width: 100%; }
    .budget-lines-table thead { display: none; }
    .budget-lines-table tr {
        display: grid;
        grid-template-columns: 1fr 1fr auto;
        grid-template-areas:
            "tipo  linea  del"
            "prod  prod   prod"
            "sku   det    det"
            "qty   price  total";
        gap: 4px 6px;
        border: 1px solid var(--gray-200);
        border-radius: var(--radius-sm);
        padding: 10px;
        margin-bottom: 8px;
        background: var(--white);
    }
    .budget-lines-table td { display: block; padding: 0; border: none; }
    .budget-lines-table td:nth-child(1) { grid-area: tipo; }
    .budget-lines-table td:nth-child(2) { grid-area: linea; }
    .budget-lines-table td:nth-child(3) { grid-area: prod; }
    .budget-lines-table td:nth-child(4) { grid-area: sku; }
    .budget-lines-table td:nth-child(5) { grid-area: det; }
    .budget-lines-table td:nth-child(6) { grid-area: qty; }
    .budget-lines-table td:nth-child(7) { grid-area: price; }
    .budget-lines-table td:nth-child(8) { grid-area: total; }
    .budget-lines-table td:nth-child(9) { grid-area: del; display: flex; justify-content: flex-end; align-items: flex-start; }
    .budget-lines-table td input,
    .budget-lines-table td select { font-size: 12px; padding: 3px 6px; }

    /* Header: título + controles apilados */
    .modal-tab-panel--presupuestos .sale-orders-wrap-header {
        flex-wrap: wrap;
        gap: 10px;
        align-items: flex-start;
        padding-bottom: 14px;
        margin-bottom: 4px;
    }

    /* Fila de controles: dos líneas — probabilidad arriba, botón abajo */
    .sale-orders-header-controls {
        width: 100%;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px !important;
        justify-content: flex-start !important;
    }

    /* Label de probabilidad: primera línea, sin crecer */
    .sale-orders-header-controls label {
        flex: 0 0 auto;
        align-items: center;
        gap: 6px !important;
        font-size: 12px !important;
        white-space: nowrap;
    }

    /* Select de probabilidad: ancho fijo para valor + flecha sin solaparse */
    .sale-orders-header-controls #lead_probability_select {
        flex: none !important;
        width: 72px !important;
        min-width: 72px !important;
        font-size: 13px !important;
        min-height: 32px;
        padding: 4px 6px !important;
    }

    /* Botón: segunda línea, ancho completo con padding lateral */
    .sale-orders-header-controls .btn {
        flex: 0 0 100%;
        text-align: center;
        justify-content: center;
        white-space: nowrap;
        min-height: 36px;
        font-size: 13px;
        padding: 6px 16px;
    }

    /* Lista de presupuestos: cards en mobile */
    .so-card-list {
        border: none;
        border-radius: 0;
        overflow: visible;
        gap: 8px;
        margin-top: 6px;
    }
    .so-card--header { display: none; }
    .so-card {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "num        date"
            "amount     currency"
            "total      contract"
            "actions    actions";
        gap: 5px 8px;
        border: 1px solid var(--gray-200);
        border-radius: var(--radius-sm);
        padding: 12px;
    }
    .so-card__num      { grid-area: num;      padding: 0; font-size: 13px; }
    .so-card__date     { grid-area: date;     padding: 0; font-size: 12px; }
    .so-card__amount   { grid-area: amount;   padding: 0; font-size: 14px; }
    .so-card__total    { grid-area: total;    padding: 0; font-size: 13px; }
    .so-card__contract { grid-area: contract; padding: 0; font-size: 12px; text-align: right; }
    .so-card__currency { grid-area: currency; padding: 0; font-size: 12px; text-align: right; }
    .so-card__state    { display: none; }
    .so-card__actions {
        grid-area: actions;
        padding: 4px 0 0;
        gap: 8px;
        white-space: normal;
    }
    .so-card__actions .btn {
        flex: 1;
        justify-content: center;
        font-size: 11px;
        padding: 4px 10px;
    }

    /* Separación clara del header */
    .sale-orders-wrap-body { padding-top: 2px; }

    /* ---- Custom select (ss-wrap): bottom-sheet on mobile ---- */
    .ss-mobile-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 2999;
    }
    .ss-wrap.open .ss-dropdown {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        border-radius: 14px 14px 0 0;
        z-index: 3000;
        max-height: 60dvh;
        max-height: 60vh;
        display: flex !important;
        flex-direction: column;
        padding-bottom: env(safe-area-inset-bottom, 0);
        overflow: hidden;
    }
    .ss-wrap.open .ss-dropdown::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: var(--gray-300);
        border-radius: 2px;
        margin: 8px auto 4px;
        flex-shrink: 0;
    }
    .ss-wrap.open .ss-dropdown .ss-search-box {
        flex-shrink: 0;
        padding: 8px 12px 10px;
    }
    .ss-wrap.open .ss-dropdown .ss-search-input {
        min-height: 44px;
        font-size: 16px;
        padding: 8px 12px;
    }
    .ss-wrap.open .ss-dropdown .ss-list {
        flex: 1;
        max-height: none;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .ss-wrap.open .ss-dropdown .ss-option {
        min-height: 44px;
        display: flex;
        align-items: center;
        padding: 0 16px;
        font-size: 15px;
        white-space: normal;
    }
    .form-group .ss-trigger {
        min-height: 44px;
        font-size: 14px;
    }
    .form-group .ss-trigger-text {
        font-size: 14px;
    }
}

/* ============================================================================
   Responsive — Contactos + Prospectos: Tablet (768px–1024px)
   ============================================================================ */

@media (min-width: 768px) and (max-width: 1024px) {
    .kanban-column {
        min-width: 220px;
        flex: 1 1 220px;
    }
    .modal-content {
        max-width: 96%;
        max-height: 94vh;
    }
    /* Contacts: kanban grid más compacto en tablet */
    .contacts-kanban-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: 16px;
    }
}

/* ============================================================================
   Dashboard view
   ============================================================================ */

.dashboard-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 16px;
}

.dashboard-kpis-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
}
@media (max-width: 1100px) { .dashboard-kpis-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px)  { .dashboard-kpis-grid { grid-template-columns: repeat(2, 1fr); } }

.dashboard-kpi-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 12px 14px 14px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.dashboard-kpi-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}
.dashboard-kpi-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.15;
}
.dashboard-kpi-value--accent  { color: var(--crimson); }
.dashboard-kpi-value--warning { color: #d97706; }
.dashboard-kpi-value--muted   { color: var(--gray-500); }
.dashboard-kpi-sub {
    font-size: 11px;
    color: var(--gray-400);
    margin-top: 3px;
}

#dash-active-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 16px;
    border-top: 1px solid var(--gray-200);
    min-height: 0;
}
#dash-active-chips:empty { display: none; }
.dash-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #fff0f3;
    border: 1px solid #fbc4cf;
    border-radius: 10px;
    padding: 2px 6px 2px 9px;
    font-size: 12px;
    white-space: nowrap;
}
.dash-chip-label { color: #b05070; }
.dash-chip-value { color: #7a1530; font-weight: 600; }
.dash-chip-remove {
    border: none;
    background: none;
    cursor: pointer;
    color: #e08090;
    font-size: 15px;
    line-height: 1;
    padding: 0 2px;
    margin-left: 1px;
}
.dash-chip-remove:hover { color: var(--crimson); }

.dashboard-widgets-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
@media (max-width: 900px) { .dashboard-widgets-row { grid-template-columns: 1fr; } }

.dashboard-widget {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 16px 20px 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.dashboard-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--gray-100);
}

.dashboard-widget-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.dashboard-widget-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}
.dashboard-widget-control-label {
    font-size: 12px;
    color: var(--gray-500);
    font-weight: 500;
}
.dash-filter-select--sm {
    font-size: 12px;
    padding: 3px 8px;
    height: 28px;
}

.dashboard-filters-wrap {
    margin-bottom: 16px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}
.dashboard-filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
    padding: 12px 16px;
}

.dash-filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dash-filter-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dash-filter-select,
.dash-filter-date {
    height: 32px;
    padding: 0 8px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: var(--white);
    font-size: 13px;
    color: var(--gray-900);
    outline: none;
    cursor: pointer;
}

.dash-filter-select:focus,
.dash-filter-date:focus {
    border-color: var(--crimson);
    box-shadow: 0 0 0 2px rgba(220, 20, 60, 0.1);
}

.dash-filter-select:disabled,
.dash-filter-date:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.dash-filter-select {
    min-width: 160px;
}

.dash-filter-date {
    min-width: 140px;
}

.dashboard-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
}

.dashboard-ctrl-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dashboard-ctrl-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.dashboard-ctrl-group .form-select {
    min-width: 200px;
    font-size: 13px;
}

.dashboard-table-panel {
    width: 100%;
}

.dashboard-paises-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.dashboard-paises-table thead th {
    padding: 7px 10px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 2px solid var(--gray-200);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    background: var(--white);
    position: sticky;
    top: 0;
    z-index: 1;
}

.dashboard-paises-table thead th:hover {
    color: var(--gray-700);
    background: var(--gray-50);
}

.dashboard-paises-table thead th:not(:first-child) {
    text-align: right;
}

.dashboard-paises-table tbody td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
    font-size: 13px;
}

.dashboard-paises-table tbody td:not(:first-child) {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.dashboard-paises-table tbody tr:hover {
    background: var(--gray-50);
}

.dashboard-row--active td {
    background: #fff0f3 !important;
}

.dashboard-pais-link {
    color: #2563eb;
    cursor: pointer;
    text-decoration: none;
}

.dashboard-pais-link:hover {
    text-decoration: underline;
}

.dash-sort-icon {
    display: inline-block;
    font-size: 10px;
    color: var(--gray-400);
    margin-left: 2px;
    min-width: 8px;
}

.dashboard-estados-table {
    width: auto;
    min-width: 220px;
    border-collapse: collapse;
    font-size: 13px;
}

.dashboard-estados-table thead th {
    padding: 7px 10px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
    background: var(--white);
    position: sticky;
    top: 0;
    z-index: 1;
}

.dashboard-estados-table thead th:nth-child(n+3) { text-align: right; }

.dashboard-estados-table tbody td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
    font-size: 13px;
}

.dashboard-estados-table tbody td.estados-dias,
.dashboard-estados-table tbody td.estados-count {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.dashboard-estados-table tbody .estados-etapa-cell {
    font-weight: 500;
    color: var(--gray-800);
}

.dashboard-estados-table tbody tr:hover { background: var(--gray-50); }

.estados-row--even td { background: #fafafa; }
.estados-row--even:hover td { background: var(--gray-50) !important; }

.estados-dias--fast { color: #16a34a; font-weight: 600; }
.estados-dias--slow { color: #d97706; font-weight: 600; }

@media (max-width: 640px) {
    /* Dashboard: menos espacio vertical */
    .dashboard-container { gap: 10px; margin-top: 8px; }

    /* Filtros: 2 por fila, sin min-width fijo */
    .dashboard-filters-bar { gap: 8px; padding: 10px 12px; }
    .dash-filter-group { flex: 1 1 calc(50% - 4px); min-width: 0; }
    .dash-filter-select,
    .dash-filter-date { min-width: 0; width: 100%; }

    /* Widget header: envolver botón de exportar */
    .dashboard-widget-header { flex-wrap: wrap; gap: 8px; }

    /* Scatter: reducir altura inline */
    #dashboard-scatter-plot { height: 280px !important; }
    #dashboard-scatter-wrapper { min-height: 280px; }

    /* Tabla países: ocultar Oport. / Gan. / Vend. — mantener País, Total, Ganado */
    #dashboard-paises-wrapper { overflow-x: auto; }
    .dashboard-paises-table th:nth-child(4),
    .dashboard-paises-table td:nth-child(4),
    .dashboard-paises-table th:nth-child(5),
    .dashboard-paises-table td:nth-child(5),
    .dashboard-paises-table th:nth-child(6),
    .dashboard-paises-table td:nth-child(6) { display: none; }
}

@media (max-width: 480px) {
    /* Filtros: 1 por fila en móvil pequeño */
    .dash-filter-group { flex: 1 1 100%; }
}

@media (min-width: 768px) {
    .prospects-ctrl-select                 { min-width: 145px; }
    .pivot-ctrl-group .form-select         { min-width: 200px; }
    .dash-filter-select                    { min-width: 200px; }
    .dash-filter-date                      { min-width: 175px; }
    .dashboard-ctrl-group .form-select     { min-width: 250px; }
}

/* ============================================================================
   Budget shared styles (budget_form + modals in budgets + prospects)
   ============================================================================ */
.btn-budget-add {
    min-width: 160px;
    padding: 5px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--crimson);
    background: transparent;
    border: 1.5px solid var(--crimson);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.btn-budget-add:hover { background: var(--crimson-light); }

.btn-section-add {
    width: 26px;
    height: 26px;
    padding: 0;
    font-size: 18px;
    font-weight: 300;
    line-height: 1;
    color: var(--crimson);
    background: transparent;
    border: 1.5px solid var(--crimson);
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}
.btn-section-add:hover { background: var(--crimson-light); }
.btn-section-add:disabled {
    color: var(--gray-400);
    border-color: var(--gray-300);
    background: transparent;
    cursor: not-allowed;
    opacity: 0.5;
}

.budget-lines-table:not(:has(tbody tr)) thead { display: none; }

/* Reactivos & Equipos: Total column matches P. unit. width */
table:has(#so-reactivos-tbody) th:nth-child(6),
table:has(#nb-reactivos-tbody) th:nth-child(6),
table:has(#reactivos-tbody) th:nth-child(6),
table:has(#so-equipos-tbody) th:nth-child(6),
table:has(#nb-equipos-tbody) th:nth-child(6),
table:has(#equipos-tbody) th:nth-child(6) { width: 90px !important; }

/* Otros: Descripción 2/3 — Monto 1/3 */
#so-otros-row-wrap .budget-lines-table,
#nb-otros-row-wrap .budget-lines-table,
#otros-row-wrap .budget-lines-table { table-layout: fixed; width: 100%; }

#so-otros-row-wrap .budget-lines-table th:first-child,
#nb-otros-row-wrap .budget-lines-table th:first-child,
#otros-row-wrap .budget-lines-table th:first-child { width: 66.67% !important; }

#so-otros-row-wrap .budget-lines-table th:last-child,
#nb-otros-row-wrap .budget-lines-table th:last-child,
#otros-row-wrap .budget-lines-table th:last-child { width: 33.33% !important; }

/* Software subsection: proportional equal-width columns */
#so-lis-row-wrap .budget-lines-table,
#nb-lis-row-wrap .budget-lines-table,
#lis-row-wrap .budget-lines-table,
#so-puestos-row-wrap .budget-lines-table,
#nb-puestos-row-wrap .budget-lines-table,
#puestos-row-wrap .budget-lines-table { table-layout: fixed; width: 100%; }

#so-lis-row-wrap .budget-lines-table th,
#nb-lis-row-wrap .budget-lines-table th,
#lis-row-wrap .budget-lines-table th,
#so-puestos-row-wrap .budget-lines-table th,
#nb-puestos-row-wrap .budget-lines-table th,
#puestos-row-wrap .budget-lines-table th { width: 20%; }

#so-ifaces-row-wrap .budget-lines-table,
#nb-ifaces-row-wrap .budget-lines-table,
#ifaces-row-wrap .budget-lines-table { table-layout: fixed; width: 100%; }

/* Interfaces thead: always visible so table-layout:fixed has <th> anchors on first paint.
   The row-wrap itself is display:none when empty, so a visible thead inside a hidden
   container costs nothing visually. */
#so-ifaces-row-wrap .budget-lines-table thead,
#nb-ifaces-row-wrap .budget-lines-table thead,
#ifaces-row-wrap .budget-lines-table thead { display: table-header-group; }

/* Interfaces columns: button column fixed, 4 data columns split the rest via calc */
#so-ifaces-row-wrap .budget-lines-table th:last-child,
#nb-ifaces-row-wrap .budget-lines-table th:last-child,
#ifaces-row-wrap .budget-lines-table th:last-child { width: 36px; }

#so-ifaces-row-wrap .budget-lines-table th:not(:last-child),
#nb-ifaces-row-wrap .budget-lines-table th:not(:last-child),
#ifaces-row-wrap .budget-lines-table th:not(:last-child) { width: calc((100% - 36px) / 4); }

/* Clip cell content to column boundary; suppress browser min-width on form elements */
#so-ifaces-row-wrap .budget-lines-table td,
#nb-ifaces-row-wrap .budget-lines-table td,
#ifaces-row-wrap .budget-lines-table td { overflow: hidden; }

#so-ifaces-row-wrap .budget-lines-table td select,
#nb-ifaces-row-wrap .budget-lines-table td select,
#ifaces-row-wrap .budget-lines-table td select,
#so-ifaces-row-wrap .budget-lines-table td input,
#nb-ifaces-row-wrap .budget-lines-table td input,
#ifaces-row-wrap .budget-lines-table td input { min-width: 0; max-width: 100%; }

.sw-subsection-title {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-500);
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: 4px;
    padding: 2px 8px;
    letter-spacing: 0.04em;
}

.budget-lines-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.budget-lines-table th {
    padding: 4px 8px;
    border: 1px solid var(--gray-200);
    text-align: left;
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
}
.budget-lines-table th .required,
.so-form-required {
    color: var(--crimson);
    font-weight: 600;
    font-size: 11px;
    margin-left: 2px;
}
.budget-lines-table td {
    padding: 4px 6px;
    border: 1px solid var(--gray-200);
}
.budget-lines-table td input,
.budget-lines-table td select {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 12px;
}
.budget-lines-table td input:focus,
.budget-lines-table td select:focus {
    outline: none;
    border-color: var(--crimson);
}

/* ============================================================================
   BUDGET FORM — Section separators (consistent across all 3 budget entry points)
   ============================================================================ */

/* Full-page form (budget_form.html) — section wrappers */
.budget-section {
    border-top: 1px solid var(--gray-200);
    padding-top: 20px;
    margin-top: 12px;
}
.budget-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.budget-section h2.form-section-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-left: 3px solid var(--crimson);
    padding-left: 8px;
    margin: 0;
}
.budget-lines-table-wrap { overflow-x: auto; }

/* Full-page form — software sub-sections (LIS / Interfaces / Puestos) */
.sw-subsection { margin-bottom: 4px; }
.sw-subsection + .sw-subsection {
    border-top: 1px solid var(--gray-200);
    padding-top: 8px;
}
.sw-subsection-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}
.sw-subsection-total {
    font-size: 12px;
    font-weight: 700;
    color: var(--crimson);
}

/* Modal budget forms (prospects.html #sale-order-form, budgets.html #new-budget-form) */
#sale-order-form > div:has(h3.modal-section-title),
#new-budget-form > div:has(h3.modal-section-title) {
    border-top: 1px solid var(--gray-200);
    padding-top: 12px;
}
#sale-order-form h3.modal-section-title,
#new-budget-form h3.modal-section-title {
    border-left: 3px solid var(--crimson);
    padding-left: 8px;
    font-size: 11px;
}
