/* ========================================
   COMPONENTES REUTILIZABLES
   ======================================== */

/* ACTION BUTTONS (audit, help, etc.) */
.sd-audit-btn {
    position: relative;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
    vertical-align: middle;
}
.sd-audit-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(206, 50, 255, 0.04);
    box-shadow: 0 2px 8px rgba(206, 50, 255, 0.12);
}
.sd-audit-btn__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    border-radius: 9999px;
    background: var(--primary);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    box-shadow: 0 2px 6px rgba(206, 50, 255, 0.35);
}

/* AUDIT TIMELINE (modal de auditoría) */
.sd-timeline {
    position: relative;
    padding: 1rem 1rem 1rem 2.25rem;
}
.sd-timeline::before {
    content: "";
    position: absolute;
    left: 1rem;
    top: 1.25rem;
    bottom: 1.25rem;
    width: 2px;
    background: linear-gradient(180deg, var(--border-color), transparent);
    border-radius: 9999px;
}
.sd-timeline__item {
    position: relative;
    padding: 0.75rem 0.875rem;
    margin-bottom: 0.625rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    transition: all 0.15s;
}
.sd-timeline__item:hover {
    border-color: var(--primary);
    box-shadow: 0 3px 12px rgba(206, 50, 255, 0.08);
    transform: translateX(2px);
}
.sd-timeline__item:last-child {
    margin-bottom: 0;
}
.sd-timeline__dot {
    position: absolute;
    left: -1.6rem;
    top: 1rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--gray-400);
    border: 3px solid var(--bg-card);
    box-shadow: 0 0 0 2px var(--border-color);
    z-index: 1;
}
.sd-timeline__dot--success { background: var(--success); box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25); }
.sd-timeline__dot--warning { background: #F59E0B; box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25); }
.sd-timeline__dot--danger  { background: var(--danger);  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.25); }
.sd-timeline__dot--info    { background: var(--primary); box-shadow: 0 0 0 2px rgba(206, 50, 255, 0.25); }
.sd-timeline__dot--gray    { background: var(--gray-400); box-shadow: 0 0 0 2px var(--border-color); }

.sd-timeline__content {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.sd-timeline__row {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-wrap: wrap;
    font-size: var(--font-size-xs);
    color: var(--text-primary);
}
.sd-timeline__row strong {
    font-weight: 700;
}
.sd-timeline__date {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 0.15rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.sd-timeline__date svg {
    flex-shrink: 0;
    opacity: 0.6;
}
.sd-timeline__entity {
    font-size: 10px;
    color: var(--text-muted);
    padding: 0.1rem 0.375rem;
    background: var(--bg-input);
    border-radius: 4px;
    border: 1px solid var(--border-color);
    font-family: monospace;
}
.sd-timeline__ip {
    font-family: monospace;
    padding: 0.05rem 0.3rem;
    background: var(--bg-input);
    border-radius: 3px;
    font-size: 9px;
    margin-left: auto;
}
.sd-timeline__details {
    font-size: 11px;
    color: var(--text-secondary);
    padding: 0.375rem 0.5rem;
    background: var(--bg-input);
    border-radius: var(--border-radius);
    border-left: 2px solid var(--primary);
    line-height: 1.5;
}
.sd-timeline__details strong {
    color: var(--text-primary);
}

/* Diff rows in audit log */
.sd-diff {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.5rem;
    background: var(--bg-input);
    border-radius: var(--border-radius);
    border: 1px dashed var(--border-color);
}
.sd-diff__row {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 11px;
    flex-wrap: wrap;
}
.sd-diff__key {
    font-weight: 700;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    min-width: 72px;
}
.sd-diff__old {
    padding: 0.1rem 0.35rem;
    background: rgba(239, 68, 68, 0.08);
    color: var(--danger);
    border-radius: 3px;
    font-family: monospace;
    font-size: 10px;
    text-decoration: line-through;
    text-decoration-color: rgba(239, 68, 68, 0.4);
}
.sd-diff__new {
    padding: 0.1rem 0.35rem;
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
    border-radius: 3px;
    font-family: monospace;
    font-size: 10px;
    font-weight: 600;
}
.sd-diff__arrow {
    color: var(--text-muted);
    font-size: 11px;
}
.sd-diff__more {
    font-size: 10px;
    color: var(--text-muted);
    font-style: italic;
    padding-top: 0.25rem;
    border-top: 1px dashed var(--border-color);
    text-align: center;
}

/* Audit modal mejorado */
.sd-audit-modal { max-width: 620px; width: 100%; }
.sd-audit-modal__header {
    background: linear-gradient(135deg, rgba(206, 50, 255, 0.08), transparent 70%);
}
.sd-audit-modal__title {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}
.sd-audit-modal__icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--gradient-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(206, 50, 255, 0.3);
}
.sd-audit-modal__label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}
.sd-audit-modal__subtitle {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    margin-top: 0.1rem;
}
.sd-audit-modal__body {
    padding: 0;
    max-height: 65vh;
    overflow-y: auto;
    background: var(--bg-input);
}
.sd-audit-modal__count {
    font-size: 11px;
    color: var(--text-muted);
    margin-right: auto;
    font-weight: 600;
}

/* Empty state del audit modal */
.sd-audit-empty {
    padding: 3rem 1.5rem;
    text-align: center;
}
.sd-audit-empty__icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--bg-card);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.75rem;
    border: 1px solid var(--border-color);
    opacity: 0.7;
}
.sd-audit-empty__text {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.25rem;
}
.sd-audit-empty__hint {
    font-size: 11px;
    color: var(--text-muted);
    margin: 0;
}

/* Scrollbar del modal de auditoría */
.sd-audit-modal__body::-webkit-scrollbar {
    width: 8px;
}
.sd-audit-modal__body::-webkit-scrollbar-track {
    background: transparent;
}
.sd-audit-modal__body::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
.sd-audit-modal__body::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* CARDS */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    max-width: 100%;
    overflow: hidden;
}

.card__header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card__title {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--text-primary);
}

.card__body {
    padding: 1.75rem;
}

/* STAT CARDS */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
    opacity: 0;
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card__icon {
    width: 44px;
    height: 44px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
    font-size: 1.25rem;
}

.stat-card__icon--blue { background: rgba(206, 50, 255, 0.1); color: #CE32FF; }
.stat-card__icon--green { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.stat-card__icon--yellow { background: rgba(245, 158, 11, 0.1); color: #F59E0B; }
.stat-card__icon--red { background: rgba(255, 62, 137, 0.1); color: #FF3E89; }

.stat-card__value {
    font-size: var(--font-size-2xl);
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 0.25rem;
}

.stat-card__label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover { text-decoration: none; }

.btn--loading { position: relative; pointer-events: none; color: transparent !important; cursor: progress; }
.btn--loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border-radius: 50%;
    border: 2px solid currentColor;
    /* Aro tenue + segmento del color del texto del botón (claro u oscuro) */
    border-color: rgba(128, 128, 128, 0.3);
    border-top-color: var(--btn-spin-color, #fff);
    animation: btnLoadingSpin 0.6s linear infinite;
}
/* Botones deshabilitados en estado de carga conservan su apariencia */
.btn--loading:disabled, .btn--loading[disabled] { opacity: 1; }
@keyframes btnLoadingSpin { to { transform: rotate(360deg); } }

/* Password field con toggle de visibilidad */
.pass-field { position: relative; }
.pass-field > .form-control { padding-right: 2.5rem; }
.pass-field__toggle {
    position: absolute;
    right: 0.55rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s;
}
.pass-field__toggle:hover { color: var(--primary); background: rgba(206, 50, 255, 0.08); }
.pass-field__toggle:focus { outline: none; box-shadow: 0 0 0 2px rgba(206, 50, 255, 0.25); }

.btn--primary {
    background: var(--gradient-primary);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 10px rgba(206, 50, 255, 0.3);
    position: relative;
    overflow: hidden;
}
.btn--primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.2s;
}
.btn--primary:hover {
    box-shadow: 0 4px 18px rgba(206, 50, 255, 0.5);
    transform: translateY(-1px);
}
.btn--primary:hover::before {
    opacity: 1;
}

.btn--secondary {
    background: var(--gray-100);
    color: var(--text-primary);
    border-color: var(--border-color);
}
.btn--secondary:hover { background: var(--gray-200); }

.btn--success {
    background: var(--success);
    color: #fff;
}
.btn--success:hover { background: #059669; }

.btn--danger {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 2px 8px rgba(255, 62, 137, 0.25);
}
.btn--danger:hover {
    background: #E6367B;
    box-shadow: 0 4px 12px rgba(255, 62, 137, 0.4);
}

.btn--warning {
    background: #F59E0B;
    color: #fff;
}
.btn--warning:hover { background: #D97706; }

.btn--sm { padding: 0.375rem 0.75rem; font-size: var(--font-size-xs); }
.btn--lg { padding: 0.75rem 1.5rem; font-size: var(--font-size-base); }

/* FORMS */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(206, 50, 255, 0.12), 0 2px 8px rgba(206, 50, 255, 0.06);
}

.form-control--error {
    border-color: var(--danger);
}

.form-error {
    font-size: var(--font-size-xs);
    color: var(--danger);
    margin-top: 0.25rem;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

/* TABLE */
.table-wrapper {
    overflow-x: auto;
}

.table {
    width: 100%;
    font-size: var(--font-size-sm);
}

.table th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--gray-50);
    border-bottom: 1px solid var(--border-color);
}

.table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.table tbody tr:hover {
    background: rgba(206, 50, 255, 0.03);
}

.table__actions {
    display: flex;
    gap: 0.5rem;
}

/* BADGES */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    border-radius: 9999px;
    font-size: var(--font-size-xs);
    font-weight: 600;
}

.badge--success { background: rgba(16, 185, 129, 0.1); color: #059669; }
.badge--warning { background: rgba(245, 158, 11, 0.1); color: #B45309; }
.badge--danger { background: rgba(255, 62, 137, 0.1); color: #E6367B; }
.badge--info { background: rgba(206, 50, 255, 0.1); color: #B02CE0; }
.badge--gray { background: var(--gray-100); color: var(--gray-700); }

/* ALERTS */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    font-size: var(--font-size-sm);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert--success { background: rgba(16, 185, 129, 0.08); color: #065F46; border: 1px solid rgba(16, 185, 129, 0.2); }
.alert--danger { background: rgba(255, 62, 137, 0.08); color: #9B1B4B; border: 1px solid rgba(255, 62, 137, 0.2); }
.alert--warning { background: rgba(245, 158, 11, 0.08); color: #92400E; border: 1px solid rgba(245, 158, 11, 0.2); }
.alert--info { background: rgba(206, 50, 255, 0.08); color: #7A1BA0; border: 1px solid rgba(206, 50, 255, 0.2); }

/* SEARCH */
.search-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.search-bar .form-control {
    max-width: 320px;
}

/* EMPTY STATE */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state__icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.empty-state__text {
    font-size: var(--font-size-lg);
    margin-bottom: 0.5rem;
}

/* TOAST NOTIFICATIONS */
.toast-container {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    min-width: 320px;
    max-width: 440px;
    padding: 1rem 1.25rem;
    border-radius: var(--border-radius-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    pointer-events: auto;
    animation: toastIn 0.35s ease;
    overflow: hidden;
    position: relative;
}

.toast--removing {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(60px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(60px); }
}

.toast__icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.toast--success .toast__icon {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
}

.toast--error .toast__icon {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

.toast--info .toast__icon {
    background: rgba(206, 50, 255, 0.12);
    color: var(--primary);
}

.toast--warning .toast__icon {
    background: rgba(245, 158, 11, 0.12);
    color: #F59E0B;
}

.toast__content {
    flex: 1;
    min-width: 0;
}

.toast__title {
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.125rem;
}

.toast__message {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}

.toast__close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.125rem;
    line-height: 1;
    font-size: 1.125rem;
    flex-shrink: 0;
    transition: color 0.15s;
}

.toast__close:hover {
    color: var(--text-primary);
}

.toast__progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
    animation: toastProgress linear forwards;
}

.toast--success .toast__progress { background: var(--success); }
.toast--error .toast__progress { background: var(--danger); }
.toast--info .toast__progress { background: var(--primary); }
.toast--warning .toast__progress { background: #F59E0B; }

@keyframes toastProgress {
    from { width: 100%; }
    to { width: 0%; }
}

@media (max-width: 480px) {
    .toast-container {
        top: auto;
        bottom: 1rem;
        right: 0.75rem;
        left: 0.75rem;
    }
    .toast {
        min-width: 0;
        max-width: 100%;
    }
}

/* CUSTOM TOOLTIPS */
[data-tip] {
    position: relative;
}

[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.95);
    background: linear-gradient(135deg, #1a1a2e, #2d1b4e);
    color: #fff;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 100;
    box-shadow: 0 4px 16px rgba(206, 50, 255, 0.2), 0 2px 4px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(206, 50, 255, 0.2);
}

[data-tip]::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1a1a2e;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 100;
}

[data-tip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

[data-tip]:hover::before {
    opacity: 1;
}

/* GENERIC MODAL (audit-log, etc.) */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 9999;
    isolation: isolate;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay--open {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    width: 100%;
    max-width: 580px;
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalIn 0.25s ease;
    overflow: hidden;
}

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

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.modal__title {
    margin: 0;
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--text-primary);
}

.modal__close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

.modal__close:hover {
    color: var(--text-primary);
}

.modal__body {
    padding: 1rem 1.25rem;
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
}

.modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* Si hay un <form> envolviendo body/footer, que herede el layout flex del modal */
.modal > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

/* CONFIRM MODAL */
.confirm-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.confirm-modal-overlay--open {
    display: flex;
}

.confirm-modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem 2rem 2rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    animation: confirmModalIn 0.25s ease;
}

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

.confirm-modal__icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 1.25rem;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(206, 50, 255, 0.12), rgba(255, 62, 137, 0.12));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--danger);
}

.confirm-modal__title {
    font-size: var(--font-size-xl);
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 0.5rem;
}

.confirm-modal__message {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    margin: 0 0 1.75rem;
    line-height: 1.6;
}

.confirm-modal__actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.confirm-modal__actions .btn {
    flex: 1;
    max-width: 160px;
    padding: 0.625rem 1.25rem;
    font-weight: 700;
}

.confirm-modal__actions .btn--danger {
    background: var(--gradient-accent);
    border: none;
    color: #fff;
}

.confirm-modal__actions .btn--danger:hover {
    opacity: 0.9;
}

@media (max-width: 480px) {
    .confirm-modal {
        padding: 2rem 1.5rem 1.5rem;
    }
    .confirm-modal__actions .btn {
        max-width: none;
    }
}

/* RESPONSIVE STATS */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .stats-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
}

/* ============================================
   Filedrop — zona de carga reutilizable (drag & drop / clic)
   ============================================ */
.filedrop { position:relative; border:2px dashed var(--border-color); border-radius:var(--border-radius-lg); padding:1.25rem 1rem; text-align:center; cursor:pointer; transition:border-color .15s, background .15s, transform .1s; background:var(--bg-input); }
.filedrop:hover { border-color:var(--primary); background:rgba(206,50,255,.04); }
.filedrop--drag { border-color:var(--primary); background:rgba(206,50,255,.09); transform:scale(1.01); }
.filedrop__input { display:none; }
.filedrop__empty { display:flex; flex-direction:column; align-items:center; gap:.1rem; }
.filedrop__empty > svg { color:var(--primary); margin-bottom:.2rem; }
.filedrop__empty img { max-width:72px; max-height:72px; border-radius:12px; object-fit:cover; margin-bottom:.4rem; }
.filedrop__text { margin:0; font-size:var(--font-size-sm); color:var(--text-secondary); }
.filedrop__text span { color:var(--primary); font-weight:700; }
.filedrop__hint { display:block; margin-top:.25rem; font-size:11px; color:var(--text-muted); }
.filedrop__items { display:none; flex-direction:column; gap:.4rem; }
.filedrop--has-file .filedrop__empty { display:none; }
.filedrop--has-file .filedrop__items { display:flex; }
.filedrop--has-file { border-style:solid; border-color:var(--primary); background:rgba(206,50,255,.05); }
.filedrop__chip { display:flex; align-items:center; gap:.6rem; text-align:left; background:var(--bg-card); border:1px solid var(--border-color); border-radius:var(--border-radius); padding:.4rem .5rem; }
.filedrop__thumb { width:38px; height:38px; border-radius:8px; flex-shrink:0; background-size:cover; background-position:center; background-color:var(--bg-input); display:flex; align-items:center; justify-content:center; color:var(--primary); }
.filedrop__thumb--icon svg { width:20px; height:20px; }
.filedrop__meta { display:flex; flex-direction:column; min-width:0; flex:1; }
.filedrop__name { font-size:var(--font-size-xs); font-weight:600; color:var(--text-primary); word-break:break-all; }
.filedrop__size { font-size:10px; color:var(--text-muted); }
.filedrop__x { width:24px; height:24px; flex-shrink:0; border:none; border-radius:50%; background:var(--danger); color:#fff; font-size:15px; line-height:1; cursor:pointer; padding:0; }

/* Alertas de vencimiento (chips de anticipación) */
.alert-days { display:flex; flex-wrap:wrap; gap:.5rem; }
.alert-day { display:flex; align-items:center; gap:.4rem; padding:.45rem .7rem; border:1px solid var(--border-color); border-radius:var(--border-radius); cursor:pointer; font-size:var(--font-size-sm); user-select:none; transition:border-color .15s, background .15s; }
.alert-day:hover { border-color:var(--primary); }
.alert-day:has(input:checked) { border-color:var(--primary); background:rgba(206,50,255,.06); color:var(--text-primary); font-weight:600; }
.alert-day input { accent-color:var(--primary); cursor:pointer; }

/* ========================================
   TAB STRIPS — scroll horizontal arrastrable sin barra visible
   ======================================== */
.crm-tabs, .stg-nav, .js-tabscroll {
    scrollbar-width: none;          /* Firefox */
    -ms-overflow-style: none;       /* IE/Edge viejo */
}
.crm-tabs::-webkit-scrollbar,
.stg-nav::-webkit-scrollbar,
.js-tabscroll::-webkit-scrollbar { display: none; }  /* Chrome/Safari */

/* Mientras se arrastra con el mouse */
.crm-tabs.is-dragging,
.stg-nav.is-dragging,
.js-tabscroll.is-dragging { cursor: grabbing; user-select: none; }
.crm-tabs.is-dragging *,
.stg-nav.is-dragging *,
.js-tabscroll.is-dragging * { pointer-events: none; }
