body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: #f8f9fa; padding: 20px; color: #333; margin: 0; }
.main-container { max-width: 1400px; margin: auto; background: white; padding: 25px; border-radius: 10px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
h1 { color: #2c3e50; margin-top: 0; }
.tabs { display: flex; gap: 10px; margin-bottom: 20px; border-bottom: 2px solid #e2e8f0; padding-bottom: 10px; }
.tab-btn { padding: 10px 20px; background: #e2e8f0; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; color: #475569; }
.tab-btn.active { background: #3498db; color: white; }
.tab-content { display: none; }
.tab-content.active { display: block; }
.upload-box { border: 2px dashed #3498db; padding: 15px; text-align: center; background: #f0f7ff; border-radius: 6px; margin-bottom: 20px; }
.workspace { display: grid; grid-template-columns: 1fr 1fr; gap: 25px; align-items: start; }
@media (max-width: 900px) { .workspace { grid-template-columns: 1fr; } }
.form-section { background: #fff; padding: 15px; border: 1px solid #e2e8f0; border-radius: 8px; }
.preview-section { background: #f8fafc; padding: 15px; border: 1px solid #e2e8f0; border-radius: 8px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.campo { display: flex; flex-direction: column; }
.campo.full { grid-column: span 2; }
label { font-size: 0.7rem; color: #64748b; font-weight: bold; text-transform: uppercase; margin-bottom: 4px; }
input, select, textarea { padding: 7px; border: 1px solid #cbd5e1; border-radius: 4px; font-size: 0.9rem; background: #f8fafc; font-family: inherit; }
textarea { resize: vertical; min-height: 60px; }
#resultados { display: none; }
iframe { width: 100%; height: 650px; border: 1px solid #cbd5e1; border-radius: 6px; background: #e2e8f0; }
.preview-placeholder { height: 650px; display: flex; align-items: center; justify-content: center; color: #94a3b8; border: 1px dashed #cbd5e1; border-radius: 6px; background: #fff; text-align: center; padding: 20px; }
.btn-action { margin-top: 15px; padding: 10px 20px; background: #27ae60; color: white; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; width: 100%; font-size: 1rem; }
.btn-action:hover { background: #219653; }
.btn-update { padding: 10px 20px; background: #2980b9; color: white; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; font-size: 0.95rem; margin-top: 15px; }
.btn-update:hover { background: #2471a3; }
.btn-open { padding: 6px 12px; background: #3498db; color: white; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; font-size: 0.8rem; text-decoration: none; display: inline-block; }
.btn-open:hover { background: #2980b9; }
.btn-delete { padding: 6px 12px; background: #e74c3c; color: white; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; font-size: 0.8rem; }
.btn-delete:hover { background: #c0392b; }

/* Estilos de la tabla y acordeón */
table { width: 100%; border-collapse: collapse; margin-top: 15px; background: white; }
th, td { border: 1px solid #cbd5e1; padding: 10px; text-align: left; font-size: 0.9rem; }
th { background: #f1f5f9; color: #334155; }
.clickable-row { cursor: pointer; transition: background 0.15s; }
.clickable-row:hover { background: #edf2f7; }
.detalles-row { display: none; background: #f8fafc; }
.detalles-row.open { display: table-row; }
.detalles-content { padding: 15px 20px; border-left: 4px solid #3498db; }
.detalles-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; font-size: 0.85rem; }
.detalles-item span { display: block; font-weight: bold; color: #64748b; font-size: 0.7rem; text-transform: uppercase; margin-bottom: 2px; }

.checklist-box { margin-top: 15px; background: #fff; padding: 15px; border: 1px solid #cbd5e1; border-radius: 6px; }
.checklist-box h5 { margin-top: 0; color: #2c3e50; font-size: 0.95rem; border-bottom: 1px solid #e2e8f0; padding-bottom: 5px; }

/* Estilos para las pestañas y bloqueo secuencial en detalles */
.wizard-steps {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 10px;
}

.step-btn {
    padding: 8px 16px;
    border: 2px solid #cbd5e1;
    background: #f8fafc;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    color: #475569;
    transition: all 0.2s ease;
}

.step-btn.active {
    border-color: #2563eb;
    background: #eff6ff;
    color: #1d4ed8;
}

.step-btn.locked {
    opacity: 0.4;
    cursor: not-allowed;
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.step-content {
    display: none;
}

.step-content.active {
    display: block;
}

/* --- ADAPTACIÓN RESPONSIVE GLOBAL PARA MÓVILES --- */
@media (max-width: 768px) {
    /* 1. Permitir scroll horizontal en las pestañas del wizard */
    .wizard-steps {
        display: flex;
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 8px;
    }

    .wizard-steps .step-btn {
        flex: 0 0 auto;
    }

    /* 2. Forzar que todos los campos de las cuadrículas ocupen el 100% */
    .grid {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .grid .campo, 
    .grid .campo.full {
        width: 100% !important;
    }

    /* 3. Barra de navegación y bloques flexibles superiores en columna */
    .main-container nav,
    div[style*="background: #f8fafc"] {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
        text-align: center;
    }

    .main-container nav a {
        text-align: center;
        display: block;
    }

    /* 4. Corrección para la caja de subida de ficheros del Extractor */
    .upload-box {
        display: flex;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
        box-sizing: border-box;
    }

    .upload-box input[type="file"], 
    div[style*="background: #f8fafc"] input[type="file"],
    div[style*="background: #f8fafc"] button {
        width: 100% !important;
        box-sizing: border-box;
        text-align: center;
    }

    /* 5. Apilar el workspace del extractor (formulario y vista previa) */
    .workspace {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
    }

    .form-section, .preview-section {
        width: 100% !important;
        box-sizing: border-box;
    }

    /* 6. Ajustar altura del visor PDF / iframes en móvil */
    iframe, .preview-placeholder {
        height: 400px !important;
    }

    /* 7. LISTA DE DOCUMENTOS DE LA CARPETA: Asegurar que no desborden */
    #lista-carpeta-expediente {
        word-break: break-word;
    }

    #lista-carpeta-expediente .row-documento,
    #lista-carpeta-expediente div {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px;
    }

    /* 8. Márgenes generales más compactos para móviles */
    .main-container {
        padding: 10px;
        margin: 10px;
    }
}