/* ===== Módulo SEPAs ===== */

/* Layout alineado con Banco / Activos / content-header (32px) */
#sepas {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#sepas .content-header {
    flex-shrink: 0;
}

#sepas-content {
    padding: 20px 32px 32px;
    flex: 1;
    min-width: 0;
    box-sizing: border-box;
}

/* Tabs principales (Domiciliaciones / Remesas) */
.sepa-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0 0 20px;
    padding: 0 0 14px;
    border-bottom: 1px solid #e5e7eb;
}
.sepa-tab {
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    border-radius: 8px;
    border-bottom: 1px solid #e5e7eb;
}
.sepa-tab:hover {
    color: #374151;
    background: #f3f4f6;
}
.sepa-tab.active {
    color: #1d4ed8;
    background: #eff6ff;
    border-color: #93c5fd;
    font-weight: 600;
}

/* Cabecera de listado */
.sepa-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.sepa-list-subtitle {
    color: #6b7280;
    font-size: 14px;
    margin: 0;
    flex: 1;
    min-width: 200px;
    line-height: 1.45;
}
.sepa-list-header .btn {
    flex-shrink: 0;
}

/* Tablas */
.sepa-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
}
.sepa-table.documentos-list-table,
.sepa-table {
    width: 100%;
    table-layout: auto;
}
.sepa-table th,
.sepa-table td {
    vertical-align: middle;
    padding: 12px 16px;
}
.sepa-table th:first-child,
.sepa-table td:first-child {
    padding-left: 20px;
}
.sepa-table th:last-child,
.sepa-table td:last-child {
    padding-right: 20px;
}

@media (max-width: 640px) {
    #sepas-content {
        padding: 16px;
    }
}
.sepa-cell-nombre { font-weight: 600; color: #111827; }
.sepa-empty { text-align: center; color: #9ca3af; padding: 28px 12px; }
.sepa-muted { color: #9ca3af; }
.sepa-warn { color: #d97706; font-weight: 700; cursor: help; }
.sepa-warn-text { color: #d97706; font-size: 13px; }

/* Columna Acciones: contenida dentro de la celda */
.sepa-table th.sepa-th-actions,
.sepa-table td.sepa-actions-cell {
    width: 1%;
    min-width: 260px;
    padding: 10px 16px;
    text-align: right;
    white-space: normal;
}
.sepa-actions {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    box-sizing: border-box;
}
.sepa-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 5px 10px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #fff;
    color: #374151;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.3;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.sepa-action-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #111827;
}
.sepa-action-btn-danger {
    color: #b91c1c;
    border-color: #fecaca;
    background: #fef2f2;
}
.sepa-action-btn-danger:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
}

/* Badges */
.sepa-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.6;
}
.sepa-badge-active { background: #dcfce7; color: #15803d; }
.sepa-badge-paused { background: #fef3c7; color: #b45309; }
.sepa-badge-draft { background: #e5e7eb; color: #4b5563; }
.sepa-badge-manual { background: #e0e7ff; color: #4338ca; }
.sepa-badge-link { background: #dbeafe; color: #1d4ed8; }
.sepa-badge-mod { background: #fef3c7; color: #b45309; }

/* ===== Editor de domiciliación (overlay propio) ===== */
.sepa-editor-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100009;
    animation: fadeIn 0.2s;
}
.sepa-editor {
    background: #fff;
    border-radius: 16px;
    width: 640px;
    max-width: 94vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.sepa-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
}
.sepa-editor-header h2 { margin: 0; font-size: 19px; font-weight: 600; color: #111827; }
.sepa-editor-body { padding: 20px 24px; overflow-y: auto; }
.sepa-editor-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid #e5e7eb;
}

.sepa-field { margin-bottom: 14px; }
.sepa-field label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 5px; }
.sepa-hint { font-size: 12px; color: #9ca3af; margin: 4px 0 0; }

.sepa-importe-box {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 14px;
}
.sepa-importe-row { display: flex; gap: 14px; }
.sepa-importe-row .sepa-field { flex: 1; }

/* Búsqueda de cliente */
.sepa-cliente-search { position: relative; }
.sepa-search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    margin-top: 4px;
    max-height: 260px;
    overflow-y: auto;
    z-index: 20;
}
.sepa-search-results.show { display: block; }
.sepa-search-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
}
.sepa-search-item:hover { background: #f3f4f6; }
.sepa-search-nif { font-size: 12px; color: #9ca3af; }
.sepa-search-empty { padding: 10px 12px; color: #9ca3af; font-size: 13px; }

.sepa-cliente-info { margin-top: 8px; }
.sepa-cliente-chip {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
    background: #f3f4f6;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 13px;
}
.sepa-cliente-chip span { color: #6b7280; font-size: 12px; }

/* ===== Modal próximos cargos ===== */
.sepa-proximos-overlay .modal-body,
.sepa-sugerencias-overlay .modal-body { padding: 20px 24px; }

.sepa-proximos-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 16px;
}
.sepa-proximos-tab {
    border: none;
    background: transparent;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.sepa-proximos-tab:hover { color: #374151; }
.sepa-proximos-tab.active { color: #2563eb; border-bottom-color: #2563eb; }
.sepa-tab-count {
    background: #e5e7eb;
    color: #4b5563;
    border-radius: 999px;
    padding: 0 7px;
    font-size: 11px;
    min-width: 18px;
    text-align: center;
}
.sepa-proximos-tab.active .sepa-tab-count { background: #dbeafe; color: #1d4ed8; }

.sepa-proximos-table { width: 100%; }
.sepa-proximos-table th:nth-child(1), .sepa-proximos-table td:nth-child(1) { width: 1%; white-space: nowrap; }
.sepa-proximos-table .btn { margin-left: 4px; padding: 3px 8px; font-size: 12px; }

.sepa-proximos-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 14px;
    font-size: 13px;
    color: #6b7280;
}

/* ===== Sugerencias remesa ===== */
.sepa-sug-title {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    margin: 18px 0 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sepa-sug-title:first-child { margin-top: 0; }
.sepa-sug-selall { font-size: 13px; font-weight: 500; color: #2563eb; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.sepa-sug-list { display: flex; flex-direction: column; gap: 6px; }
.sepa-sug-item {
    display: grid;
    grid-template-columns: 22px 1.4fr 1.6fr auto;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    cursor: pointer;
}
.sepa-sug-item:hover { background: #f9fafb; }
.sepa-sug-incluida { opacity: 0.6; cursor: default; }
.sepa-sug-nombre { font-weight: 600; color: #111827; }
.sepa-sug-detalle { color: #6b7280; font-size: 13px; }
.sepa-sug-importe { text-align: right; font-weight: 600; color: #111827; }

/* ===== Detalle de remesa ===== */
.sepa-remesa-detalle-header {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.sepa-remesa-titulo { flex: 1; min-width: 220px; }
.sepa-remesa-titulo h2 { margin: 0; font-size: 19px; color: #111827; display: flex; align-items: center; gap: 10px; }
.sepa-remesa-titulo p { margin: 4px 0 0; color: #6b7280; font-size: 13px; }
.sepa-remesa-acciones { display: flex; gap: 8px; flex-wrap: wrap; }
